aboutsummaryrefslogtreecommitdiffstats
path: root/src/build-data/cmake.in
blob: 16c2b1aeb642019d93b1b39cab563cfd15f46040 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
cmake_minimum_required(VERSION 2.8.0)
project(botan)

if(POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
endif()

set(BOTAN_SOURCES
%{for lib_srcs}
    "%{i}"
%{endfor}
)

set(BOTAN_CLI
%{for cli_srcs}
    "%{i}"
%{endfor}
)

set(BOTAN_TESTS
%{for test_srcs}
    "%{i}"
%{endfor}
)

%{for isa_build_info}
set_source_files_properties("%{src}" PROPERTIES COMPILE_FLAGS "%{isa_flags}")
%{endfor}

option(ENABLED_OPTIONAL_WARINIGS "If enabled more strict warning policy will be used" OFF)
option(ENABLED_LTO "If enabled link time optimization will be used" OFF)

set(COMPILER_FEATURES_RELEASE %{cc_lang_flags} %{cc_compile_opt_flags} %{cxx_abi_opt_flags})
set(COMPILER_FEATURES_DEBUG %{cc_lang_flags} %{cc_compile_debug_flags} %{cxx_abi_debug_flags})
set(COMPILER_FEATURES $<$<NOT:$<CONFIG:DEBUG>>:${COMPILER_FEATURES_RELEASE}>  $<$<CONFIG:DEBUG>:${COMPILER_FEATURES_DEBUG}>)
set(SHARED_FEATURES %{cmake_lib_flags})
set(STATIC_FEATURES -DBOTAN_DLL=)
set(COMPILER_WARNINGS %{cc_warning_flags})
set(COMPILER_INCLUDE_DIRS build/include build/include/external)
if(ENABLED_LTO)
    set(COMPILER_FEATURES ${COMPILER_FEATURES} -lto)
endif()
if(ENABLED_OPTIONAL_WARINIGS)
    set(COMPILER_OPTIONAL_WARNINGS -Wsign-promo -Wctor-dtor-privacy -Wdeprecated -Winit-self -Wnon-virtual-dtor -Wunused-macros -Wold-style-cast -Wuninitialized)
endif()

add_library(${PROJECT_NAME} STATIC ${BOTAN_SOURCES})
target_link_libraries(${PROJECT_NAME} PUBLIC  %{cmake_link_to})
target_compile_options(${PROJECT_NAME} PUBLIC ${COMPILER_WARNINGS} ${COMPILER_FEATURES} ${COMPILER_OPTIONAL_WARNINGS} PRIVATE ${STATIC_FEATURES})
target_include_directories(${PROJECT_NAME} PUBLIC ${COMPILER_INCLUDE_DIRS})

set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME ${PROJECT_NAME}-static)

add_library(${PROJECT_NAME}_shared SHARED ${BOTAN_SOURCES})
target_link_libraries(${PROJECT_NAME}_shared PUBLIC  %{cmake_link_to})
target_compile_options(${PROJECT_NAME}_shared PUBLIC ${COMPILER_WARNINGS} ${COMPILER_FEATURES} ${COMPILER_OPTIONAL_WARNINGS} PRIVATE ${SHARED_FEATURES})
target_include_directories(${PROJECT_NAME}_shared PUBLIC ${COMPILER_INCLUDE_DIRS})
set_target_properties(${PROJECT_NAME}_shared PROPERTIES OUTPUT_NAME ${PROJECT_NAME})

add_executable(${PROJECT_NAME}_cli ${BOTAN_CLI})
target_link_libraries(${PROJECT_NAME}_cli PRIVATE ${PROJECT_NAME}_shared  )
set_target_properties(${PROJECT_NAME}_cli PROPERTIES OUTPUT_NAME ${PROJECT_NAME}-cli)

add_executable(${PROJECT_NAME}_tests ${BOTAN_TESTS})
target_link_libraries(${PROJECT_NAME}_tests PRIVATE ${PROJECT_NAME}_shared  )
set_target_properties(${PROJECT_NAME}_tests PROPERTIES OUTPUT_NAME botan-test)

set(GLOBAL_CONFIGURATION_FILES configure.py .gitignore news.rst readme.rst)
file(GLOB_RECURSE CONFIGURATION_FILES src/configs/* )
file(GLOB_RECURSE DOCUMENTATION_FILES doc/* )
file(GLOB_RECURSE HEADER_FILES src/*.h )
file(GLOB_RECURSE INFO_FILES src/lib/*info.txt )
add_custom_target(CONFIGURATION_DUMMY SOURCES ${GLOBAL_CONFIGURATION_FILES} ${CONFIGURATION_FILES} ${DOCUMENTATION_FILES} ${INFO_FILES} ${HEADER_FILES})