-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Add basic CMake support files to cpp generation.
1 parent
53ca56b
commit 5ee1b65
Showing
6 changed files
with
91 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
cmake_minimum_required (VERSION 3.10) | ||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
project({{project_name}}) | ||
|
||
# Set a default build type if none was specified | ||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) | ||
message(STATUS "Setting build type to 'Release' as none was specified.") | ||
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE) | ||
# Set the possible values of build type for cmake-gui | ||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" | ||
"MinSizeRel" "RelWithDebInfo") | ||
endif() | ||
|
||
find_package(Git QUIET) | ||
|
||
include(CTest) | ||
set(JSON_BuildTests OFF CACHE INTERNAL "") | ||
|
||
option(${PROJECT_NAME}_BUILD_TESTING "Build ${PROJECT_NAME} testing targets" OFF) | ||
option(${PROJECT_NAME}_COVERAGE "Add ${PROJECT_NAME} coverage reports" OFF) | ||
|
||
#set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) | ||
#include(compiler-flags) | ||
|
||
add_subdirectory(src) | ||
|
||
if (${PROJECT_NAME}_BUILD_TESTING) | ||
enable_testing() | ||
add_subdirectory(test) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
file(GLOB lib_headers "${PROJECT_SOURCE_DIR}/include/{{project_name}}/*.h") | ||
file(GLOB lib_src "${PROJECT_SOURCE_DIR}/src/*.cpp") | ||
|
||
set (sources "${lib_headers}" | ||
"${lib_src}") | ||
|
||
option(${PROJECT_NAME}_STATIC_LIB "Make ${PROJECT_NAME} a static library" ON) | ||
|
||
if (${PROJECT_NAME}_STATIC_LIB) | ||
add_library(${PROJECT_NAME} STATIC ${sources}) | ||
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-D${PROJECT_NAME}_STATIC_DEFINE") | ||
else () | ||
set(CMAKE_MACOSX_RPATH 1) | ||
add_library(${PROJECT_NAME} SHARED ${sources}) | ||
endif () | ||
|
||
#target_link_libraries({{project_name}} PUBLIC courierr fmt nlohmann_json) | ||
target_include_directories({{project_name}} PUBLIC ${PROJECT_SOURCE_DIR}/include/{{project_name}}) | ||
|
||
target_compile_options(${PROJECT_NAME} PRIVATE | ||
$<$<CXX_COMPILER_ID:MSVC>:/W4> | ||
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>: | ||
-Wall -Wextra -Wpedantic> | ||
) | ||
|
||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) | ||
include(GenerateExportHeader) | ||
generate_export_header(${PROJECT_NAME}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters