GithubHelp home page GithubHelp logo

wang-bin / cmake_templates Goto Github PK

View Code? Open in Web Editor NEW

This project forked from acdemiralp/cmake_templates

1.0 2.0 0.0 96 KB

A set of cmake templates for creating a C++ library or executable.

CMake 1.39% C++ 98.61%

cmake_templates's Introduction

cmake_templates

A set of cmake templates for creating a C++ library or executable.

Instructions to configure into an actual project (also available in respective CMakeLists.txts):

  • Copy the chosen project template somewhere.
  • Rename the folder include/PROJECT_NAME_HERE/.
  • Open up CMakeLists.txt.
  • Change PROJECT_NAME_HERE to your project name.
#################################################    Project     #################################################
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
project               (PROJECT_NAME_HERE VERSION 1.0 LANGUAGES CXX)
list                  (APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
  • Add your source files to the PROJECT_SOURCES list.
#################################################    Sources     #################################################
set(PROJECT_SOURCES
  CMakeLists.txt
  cmake/assign_source_group.cmake
  cmake/import_library.cmake
  
  # ADD HEADERS AND SOURCES HERE. EXAMPLES:
  include/example_project/example_header.hpp
  source/example_source.cpp
)
  • Add your third party libraries via the import_library function which creates a cmake library target for the given include directories and libraries. You may also choose to manually add your libraries to the PROJECT_LIBRARIES list.
#################################################  Dependencies  #################################################
include(import_library)

# ADD LIBRARIES HERE. EXAMPLES:
# Header Only:
find_package  (GLM REQUIRED)
import_library(GLM_INCLUDE_DIRS)
# Identical Debug and Release:
find_package  (OpenGL REQUIRED)
import_library(OPENGL_INCLUDE_DIR OPENGL_LIBRARIES)
# Separate Debug and Release:
find_package  (Boost REQUIRED iostreams)
import_library(Boost_INCLUDE_DIRS Boost_IOSTREAMS_LIBRARY_DEBUG Boost_IOSTREAMS_LIBRARY_RELEASE)
  • Add your test files to the PROJECT_TEST_SOURCES list (optional).
#################################################    Testing     #################################################
if(BUILD_TESTS)
  enable_testing()
  set(PROJECT_TEST_SOURCES
    # ADD TESTS HERE. EXAMPLES:
    tests/example_test.cpp
  )
endif()
  • Extend as you like.

cmake_templates's People

Contributors

acdemiralp avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.