Giter Site home page Giter Site logo

dongleigryphonsecure / cmake_templates Goto Github PK

View Code? Open in Web Editor NEW

This project forked from acdemiralp/cmake_templates

0.0 0.0 0.0 295 KB

Concise CMake templates for creating C++ libraries or executables.

Shell 0.21% C++ 80.62% Python 0.64% CMake 18.33% Batchfile 0.20%

cmake_templates's Introduction

cmake_templates

Concise cmake templates for creating C++ libraries and executables.

Creating a normal cmake project

  • Copy the chosen project template somewhere.
  • Rename the folder include/PROJECT_NAME_HERE/.
  • Open CMakeLists.txt and change PROJECT_NAME_HERE.
#################################################    Project     #################################################
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
project               (PROJECT_NAME_HERE VERSION 1.0 LANGUAGES CXX)
list                  (APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
...
  • 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 set the PROJECT_INCLUDE_DIRS and PROJECT_LIBRARIES variables manually instead of using import_library.
...
#################################################  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)
...

Creating a conan cmake project

  • Copy the chosen project template somewhere.
  • Rename the folder include/PROJECT_NAME_HERE/.
  • Open CMakeLists.txt and change PROJECT_NAME_HERE.
#################################################    Project     #################################################
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
project               (PROJECT_NAME_HERE VERSION 1.0 LANGUAGES CXX)
list                  (APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
...
  • Open conanfile.py, change PROJECT_NAME_HERE as well as PROJECT_URL_HERE (if available) and add your third party libraries to the requires.
...
class Project(ConanFile):
    name            = "PROJECT_NAME_HERE"
    description     = "Conan package for PROJECT_NAME_HERE."
    version         = "1.0.0"                
    url             = "PROJECT_URL_HERE"
    settings        = "arch", "build_type", "compiler", "os"
    generators      = "cmake"
    requires        = (("doctest/2.3.4@bincrafters/stable")) 
    ...

Creating a vcpkg cmake project

  • Copy the chosen project template somewhere.
  • Rename the folder include/PROJECT_NAME_HERE/.
  • Open CMakeLists.txt and change PROJECT_NAME_HERE.
#################################################    Project     #################################################
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
project               (PROJECT_NAME_HERE VERSION 1.0 LANGUAGES CXX)
list                  (APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
...
  • 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 set the PROJECT_INCLUDE_DIRS and PROJECT_LIBRARIES variables manually instead of using import_library.
...
#################################################  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)
...
  • Open bootstrap.bat and bootstrap.sh, and add your third party library ports.
...
rem Add your library ports here.
%VCPKG_COMMAND% doctest
...
...
# Add your library ports here. 
$VCPKG_COMMAND doctest
...

cmake_templates's People

Contributors

acdemiralp 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.