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

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
<#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>
Jean Meurice's avatar
Jean Meurice committed
14
<#if var.fortranQuadMath>set(LIBS ${r"${LIBS}"} "quadmath")</#if>
15
16
</#list>

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

22
23
# create static library
include_directories(${r"${INCLUDE_DIRS}"})
24
add_library(${viewModel.compName} ${viewModel.compName}.cpp)
25
target_include_directories(${viewModel.compName} PUBLIC ${r"${CMAKE_CURRENT_SOURCE_DIR}"} ${r"${INCLUDE_DIRS}"})
26
27
28
29
30
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)
31
32
33

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