CMakeListsCppTemplate.ftl 1.19 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
cmake_minimum_required(VERSION 3.5)
set(CMAKE_CXX_STANDARD 11)

project(${viewModel.compName} LANGUAGES CXX)

#set cmake module path
set(CMAKE_MODULE_PATH ${r"${CMAKE_MODULE_PATH}"} ${r"${CMAKE_CURRENT_SOURCE_DIR}"}/cmake)

# add dependencies
<#list viewModel.moduleDependencies as var>
11
find_package(${var.packageName} <#if var.required>REQUIRED<#else></#if>)
12
13
14
15
<#if var.findPath>set(INCLUDE_DIRS ${r"${INCLUDE_DIRS}"} ${r"${"}${var.packageName}${r"_INCLUDE_DIRS}"})</#if>
<#if var.findLibrary>set(LIBS ${r"${LIBS}"} ${r"${"}${var.packageName}${r"_LIBRARIES}"})</#if>
</#list>

16
17
18
19
20
# additional commands
<#list viewModel.cmakeCommandList as cmd>
${cmd}
</#list>

21
22
23
# create static library
include_directories(${r"${INCLUDE_DIRS}"})
add_library(${viewModel.compName} ${viewModel.compName}.h)
24
target_include_directories(${viewModel.compName} PUBLIC ${r"${CMAKE_CURRENT_SOURCE_DIR}"} ${r"${INCLUDE_DIRS}"})
25
26
27
28
29
target_link_libraries(${viewModel.compName} PUBLIC ${r"${LIBS}"})
set_target_properties(${viewModel.compName} PROPERTIES LINKER_LANGUAGE CXX)

# export cmake project
export(TARGETS ${viewModel.compName} FILE ${viewModel.compName}.cmake)
30
31
32

# additional commands end
<#list viewModel.cmakeCommandListEnd as cmd>
33
${cmd}
34
</#list>