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 $<$>:${COMPILER_FEATURES_RELEASE}> $<$:${COMPILER_FEATURES_DEBUG}>) set(SHARED_FEATURES %{cmake_lib_flags}) set(STATIC_FEATURES -DBOTAN_DLL=) set(COMPILER_WARNINGS %{cc_warning_flags}) set(COMPILER_INCLUDE_DIRS %{compiler_include_dirs}) 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})