релиз
This commit is contained in:
42
templates/CMakeLists.txt.jinja
Normal file
42
templates/CMakeLists.txt.jinja
Normal file
@@ -0,0 +1,42 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
project({{ project_name_cmake }})
|
||||
|
||||
option({{ project_name | replace(" ", "_") | upper }}_BUILD_TESTS "Build {{ project_name }} tests" OFF)
|
||||
option({{ project_name | replace(" ", "_") | upper }}_BUILD_EXAMPLES "Build {{ project_name }} examples" OFF)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
|
||||
set(default_build_type "Release")
|
||||
set(CMAKE_CXX_FLAGS "-Wall ${CMAKE_CXX_FLAGS}")
|
||||
|
||||
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
|
||||
message(STATUS "Build type is release. Optimization for speed, without debug info.")
|
||||
add_compile_options(-Ofast -s)
|
||||
elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
|
||||
message(STATUS "Minimal optimization, debug info included")
|
||||
add_compile_options(-g)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0")
|
||||
add_definitions(-DUSE_DEBUG)
|
||||
else()
|
||||
message(FATAL_ERROR "You must set build type \"Debug\" or \"Release\". Another build types not supported!")
|
||||
endif()
|
||||
|
||||
message("{{ project_name }} CXX Flags: " ${CMAKE_CXX_FLAGS})
|
||||
message("{{ project_name }} CMAKE_BUILD_TYPE: " ${CMAKE_BUILD_TYPE})
|
||||
|
||||
add_library(${PROJECT_NAME} STATIC
|
||||
include/{{ include_header }}
|
||||
src/{{ namespace }}.cpp
|
||||
)
|
||||
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC include/)
|
||||
|
||||
if ({{ project_name | replace(" ", "_") | upper }}_BUILD_EXAMPLES)
|
||||
message("Build examples enabled")
|
||||
{% for ex in examples_names %} add_subdirectory(examples/{{ ex | replace(" ", "-") | lower }})
|
||||
{% endfor %}endif()
|
||||
|
||||
if ({{ project_name | replace(" ", "_") | upper }}_BUILD_TESTS)
|
||||
message("Build tests enabled")
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
Reference in New Issue
Block a user