diff options
author | Jack Lloyd <[email protected]> | 2017-12-11 15:59:25 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-12-11 15:59:25 -0500 |
commit | 479fd4036f3bfa656f0801abf0d3e83a58c5ed71 (patch) | |
tree | 33e944f7f7757240c47fea97a800d2fbdd3880fd /src/build-data | |
parent | 95c5eae4ed34331d0e54496d783b6b46e9077a47 (diff) | |
parent | 4f2ad34ea2cb24e2310dce4e7b3f3f9b19c090f5 (diff) |
Merge GH #1346 Add for loops to templates, add cmake+bakefile templates
Diffstat (limited to 'src/build-data')
-rw-r--r-- | src/build-data/bakefile.in | 51 | ||||
-rw-r--r-- | src/build-data/cmake.in | 73 | ||||
-rw-r--r-- | src/build-data/makefile.in | 34 |
3 files changed, 148 insertions, 10 deletions
diff --git a/src/build-data/bakefile.in b/src/build-data/bakefile.in new file mode 100644 index 000000000..a1c0ff134 --- /dev/null +++ b/src/build-data/bakefile.in @@ -0,0 +1,51 @@ +toolsets = vs2013; +shared-library botan { + defines = "BOTAN_DLL=__declspec(dllexport)"; + sources { +%{for lib_srcs} + %{i} +%{endfor} + } +} + +program cli { + deps = botan; + sources { +%{for cli_srcs} + %{i} +%{endfor} + } + + headers { +%{for cli_headers} + %{i} +%{endfor} + } + +} + +program tests { + deps = botan; + sources { +%{for test_srcs} + %{i} +%{endfor} + } +} + +includedirs += build/include/; +includedirs += build/include/external; + +%{for libs_used} +libs += "%{i}"; +%{endfor} + +archs = %{bakefile_arch}; + +vs2013.option.ClCompile.DisableSpecificWarnings = "4250;4251;4275"; +vs2013.option.ClCompile.WarningLevel = Level4; +vs2013.option.ClCompile.ExceptionHandling = SyncCThrow; +vs2013.option.ClCompile.RuntimeTypeInfo = true; +if ( $(config) == Release ) { + vs2013.option.Configuration.WholeProgramOptimization = true; +} diff --git a/src/build-data/cmake.in b/src/build-data/cmake.in new file mode 100644 index 000000000..eadf7d471 --- /dev/null +++ b/src/build-data/cmake.in @@ -0,0 +1,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} + "${CMAKE_CURRENT_LIST_DIR}/%{i}" +%{endfor} +) + +set(BOTAN_CLI +%{for cli_srcs} + "${CMAKE_CURRENT_LIST_DIR}/%{i}" +%{endfor} +) + +set(BOTAN_TESTS +%{for test_srcs} + "${CMAKE_CURRENT_LIST_DIR}/%{i}" +%{endfor} +) + +%{for isa_build_info} +set_source_files_properties("${CMAKE_CURRENT_LIST_DIR}/%{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_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_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}) diff --git a/src/build-data/makefile.in b/src/build-data/makefile.in index 9262bfd06..86a2f4f3f 100644 --- a/src/build-data/makefile.in +++ b/src/build-data/makefile.in @@ -59,11 +59,11 @@ install: libs cli docs $(PYTHON_EXE) $(SCRIPTS_DIR)/install.py --prefix=%{prefix} --build-dir="%{build_dir}" --bindir=%{bindir} --libdir=%{libdir} --docdir=%{docdir} --includedir=%{includedir} # Object Files -LIBOBJS = %{lib_objs} +LIBOBJS = %{join lib_objs} -CLIOBJS = %{cli_objs} +CLIOBJS = %{join cli_objs} -TESTOBJS = %{test_objs} +TESTOBJS = %{join test_objs} # Executable targets @@ -77,7 +77,7 @@ $(TEST): $(LIBRARIES) $(TESTOBJS) %{if build_fuzzers} -FUZZERS=%{fuzzer_bin} +FUZZERS = %{fuzzer_bin} fuzzers: libs $(FUZZERS) @@ -115,12 +115,26 @@ fuzzer_corpus_zip: fuzzer_corpus %{endif} # Build Commands -%{lib_build_cmds} -%{cli_build_cmds} +%{for lib_build_info} +%{obj}: %{src} + $(CXX) %{isa_flags} $(%{target_type}_FLAGS) %{include_paths} %{dash_c} %{src} %{dash_o}$@ +%{endfor} -%{test_build_cmds} +%{for cli_build_info} +%{obj}: %{src} + $(CXX) %{isa_flags} $(%{target_type}_FLAGS) %{include_paths} %{dash_c} %{src} %{dash_o}$@ +%{endfor} -%{if build_fuzzers} -%{fuzzer_build_cmds} -%{endif} +%{for test_build_info} +%{obj}: %{src} + $(CXX) %{isa_flags} $(%{target_type}_FLAGS) %{include_paths} %{dash_c} %{src} %{dash_o}$@ +%{endfor} + +%{for fuzzer_build_info} +%{obj}: %{src} + $(CXX) %{isa_flags} $(%{target_type}_FLAGS) %{include_paths} %{dash_c} %{src} %{dash_o}$@ + +%{exe}: %{obj} $(LIBRARIES) + $(EXE_LINK_CMD) %{obj} $(EXE_LINKS_TO) %{fuzzer_lib} %{output_to_exe}$@ +%{endfor} |