aboutsummaryrefslogtreecommitdiffstats
path: root/src/build-data/cmake.in
blob: 4fa9060088579d4f63eab2a75ef96609f5efa5e6 (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
cmake_minimum_required(VERSION 2.8.0)
project(botan)

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

set(BOTAN_SOURCES
%{cmake_lib_sources})

set(BOTAN_CLI
%{cmake_cli_sources})

set(BOTAN_TESTS
%{cmake_test_sources})

%{cmake_compile_properties}

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_flags} %{cxx_abi_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_shared_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_libs_used})
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_libs_used})
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})