Skip to content

Commit

Permalink
Build third-party libraries in Release mode on Linux
Browse files Browse the repository at this point in the history
Building with debug symbols or in Debug mode is too slow,
requires too much disk space and RAM.
We can eventually add an option to choose the flags for debugging
reasons.
  • Loading branch information
Smjert committed Aug 16, 2019
1 parent a88e558 commit da0b237
Show file tree
Hide file tree
Showing 37 changed files with 120 additions and 69 deletions.
55 changes: 55 additions & 0 deletions cmake/utilities.cmake
Expand Up @@ -498,3 +498,58 @@ function(generateSpecialTargets)
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
VERBATIM)
endfunction()

function(copyInterfaceTargetFlagsTo destination_target source_target)

set(target_list ${source_target})
set(target_list_length 1)

while(${target_list_length} GREATER 0)
foreach(target ${target_list})

if(NOT TARGET ${target})
continue()
endif()

get_target_property(target_type ${target} TYPE)

if(NOT "${target_type}" STREQUAL "INTERFACE_LIBRARY")
continue()
endif()

get_target_property(dependencies ${target} INTERFACE_LINK_LIBRARIES)

if(NOT "${dependencies}" STREQUAL "dependencies-NOTFOUND")
list(APPEND new_target_list ${dependencies})
endif()

get_target_property(compile_options ${target} INTERFACE_COMPILE_OPTIONS)
get_target_property(compile_definitions ${target} INTERFACE_COMPILE_DEFINITIONS)
get_target_property(link_options ${target} INTERFACE_LINK_OPTIONS)

if(NOT "${compile_options}" STREQUAL "compile_options-NOTFOUND")
list(APPEND compile_options_list ${compile_options})
endif()

if(NOT "${compile_definitions}" STREQUAL "compile_definitions-NOTFOUND")
list(APPEND compile_definitions_list ${compile_definitions})
endif()

if(NOT "${link_options}" STREQUAL "link_options-NOTFOUND")
list(APPEND link_options_list ${link_options})
endif()
endforeach()

set(target_list ${new_target_list})
list(LENGTH target_list target_list_length)
unset(new_target_list)
endwhile()

list(REMOVE_DUPLICATES compile_options_list)
list(REMOVE_DUPLICATES compile_definitions_list)
list(REMOVE_DUPLICATES link_options_list)

target_compile_options(${destination_target} PUBLIC ${compile_options_list})
target_compile_definitions(${destination_target} PUBLIC ${compile_definitions_list})
target_link_options(${destination_target} PUBLIC ${link_options_list})
endfunction()
4 changes: 2 additions & 2 deletions libraries/cmake/source/augeas/CMakeLists.txt
Expand Up @@ -128,7 +128,7 @@ function(augeasMain)
)

target_link_libraries(thirdparty_augeas PRIVATE
thirdparty_source_module_warnings
thirdparty_source_module_settings
)

target_include_directories(thirdparty_augeas PRIVATE
Expand Down Expand Up @@ -160,7 +160,7 @@ function(importSELinux)
)

target_link_libraries(thirdparty_selinux PRIVATE
thirdparty_source_module_warnings
thirdparty_source_module_settings
)

target_include_directories(thirdparty_selinux SYSTEM INTERFACE
Expand Down
16 changes: 8 additions & 8 deletions libraries/cmake/source/aws-sdk-cpp/CMakeLists.txt
Expand Up @@ -109,7 +109,7 @@ function(generateAwsCcommonTarget)
)

target_link_libraries(thirdparty_aws_c_common PRIVATE
thirdparty_source_module_warnings
thirdparty_source_module_settings
)
endfunction()

Expand All @@ -134,7 +134,7 @@ function(generateAwsChecksumsTarget)
)

target_link_libraries(thirdparty_aws_checksums PRIVATE
thirdparty_source_module_warnings
thirdparty_source_module_settings
)
endfunction()

Expand All @@ -159,7 +159,7 @@ function(generateAwsCeventStreamTarget)
)

target_link_libraries(thirdparty_aws_c_event_stream PRIVATE
thirdparty_source_module_warnings
thirdparty_source_module_settings
)
endfunction()

Expand Down Expand Up @@ -327,7 +327,7 @@ function(generateAwsCore)
)

target_link_libraries(thirdparty_aws_core PRIVATE
thirdparty_source_module_warnings
thirdparty_source_module_settings
)
endfunction()

Expand Down Expand Up @@ -438,7 +438,7 @@ function(generateAwsFirehose)
)

target_link_libraries(thirdparty_aws_firehose PRIVATE
thirdparty_source_module_warnings
thirdparty_source_module_settings
)
endfunction()

Expand Down Expand Up @@ -527,7 +527,7 @@ function(generateAwsKinesis)
)

target_link_libraries(thirdparty_aws_kinesis PRIVATE
thirdparty_source_module_warnings
thirdparty_source_module_settings
)
endfunction()

Expand Down Expand Up @@ -1748,7 +1748,7 @@ function(generateAwsEc2)
)

target_link_libraries(thirdparty_aws_ec2 PRIVATE
thirdparty_source_module_warnings
thirdparty_source_module_settings
)
endfunction()

Expand Down Expand Up @@ -1793,7 +1793,7 @@ function(generateAwsSts)
)

target_link_libraries(thirdparty_aws_sts PRIVATE
thirdparty_source_module_warnings
thirdparty_source_module_settings
)
endfunction()

Expand Down
2 changes: 1 addition & 1 deletion libraries/cmake/source/berkeley-db/CMakeLists.txt
Expand Up @@ -287,7 +287,7 @@ function(berkeleydbMain)
)

target_link_libraries(thirdparty_berkeley-db PRIVATE
thirdparty_source_module_warnings
thirdparty_source_module_settings
)

target_include_directories(thirdparty_berkeley-db PRIVATE
Expand Down
2 changes: 1 addition & 1 deletion libraries/cmake/source/bzip2/CMakeLists.txt
Expand Up @@ -32,7 +32,7 @@ function(bzip2Main)
)

target_link_libraries(thirdparty_bzip2 PRIVATE
thirdparty_source_module_warnings
thirdparty_source_module_settings
)

target_include_directories(thirdparty_bzip2 PRIVATE
Expand Down
15 changes: 4 additions & 11 deletions libraries/cmake/source/gflags/CMakeLists.txt
Expand Up @@ -9,23 +9,16 @@ function(gflagsMain)
set(BUILD_gflags_LIB true CACHE BOOL "" FORCE)

set(library_root "${CMAKE_CURRENT_SOURCE_DIR}/src")

add_subdirectory("${library_root}" "${CMAKE_CURRENT_BINARY_DIR}/submodule" EXCLUDE_FROM_ALL)

set(compile_options_target_list
global_settings
cxx_settings
thirdparty_source_module_warnings
global_cxx_settings
thirdparty_source_module_settings
)

foreach(compile_options_target ${compile_options_target_list})
get_target_property(flag_list
"${compile_options_target}"
INTERFACE_COMPILE_OPTIONS
)

target_compile_options(gflags_static PUBLIC
${flag_list}
)
copyInterfaceTargetFlagsTo(gflags_static ${compile_options_target})
endforeach()

add_library(thirdparty_gflags INTERFACE)
Expand Down
14 changes: 3 additions & 11 deletions libraries/cmake/source/glog/CMakeLists.txt
Expand Up @@ -27,20 +27,12 @@ function(googleLogMain)
add_subdirectory("${library_root}" "${CMAKE_CURRENT_BINARY_DIR}/submodule" EXCLUDE_FROM_ALL)

set(compile_options_target_list
global_settings
cxx_settings
thirdparty_source_module_warnings
global_cxx_settings
thirdparty_source_module_settings
)

foreach(compile_options_target ${compile_options_target_list})
get_target_property(flag_list
"${compile_options_target}"
INTERFACE_COMPILE_OPTIONS
)

target_compile_options(glog PUBLIC
${flag_list}
)
copyInterfaceTargetFlagsTo(glog ${compile_options_target})
endforeach()

get_target_property(gflags_include_directory thirdparty_gflags INTERFACE_INCLUDE_DIRECTORIES)
Expand Down
2 changes: 1 addition & 1 deletion libraries/cmake/source/googletest/CMakeLists.txt
Expand Up @@ -43,7 +43,7 @@ function(googleTestMain)
)

target_link_libraries("${target_name}" PRIVATE
thirdparty_source_module_warnings
thirdparty_source_module_settings
)
endforeach()

Expand Down
2 changes: 1 addition & 1 deletion libraries/cmake/source/libarchive/CMakeLists.txt
Expand Up @@ -161,7 +161,7 @@ function(libarchiveMain)
)

target_link_libraries(thirdparty_libarchive PRIVATE
thirdparty_source_module_warnings
thirdparty_source_module_settings
)

target_include_directories(thirdparty_libarchive PRIVATE
Expand Down
2 changes: 1 addition & 1 deletion libraries/cmake/source/libaudit/CMakeLists.txt
Expand Up @@ -28,7 +28,7 @@ function(libauditMain)
)

target_link_libraries(thirdparty_libaudit PRIVATE
thirdparty_source_module_warnings
thirdparty_source_module_settings
)

target_include_directories(thirdparty_libaudit PRIVATE
Expand Down
2 changes: 1 addition & 1 deletion libraries/cmake/source/libcryptsetup/CMakeLists.txt
Expand Up @@ -60,7 +60,7 @@ function(libcryptsetupMain)
)

target_link_libraries(thirdparty_libcryptsetup PRIVATE
thirdparty_source_module_warnings
thirdparty_source_module_settings
)

target_include_directories(thirdparty_libcryptsetup PRIVATE
Expand Down
2 changes: 1 addition & 1 deletion libraries/cmake/source/libdevmapper/CMakeLists.txt
Expand Up @@ -136,7 +136,7 @@ function(libdevmapperMain)
)

target_link_libraries(thirdparty_libdevmapper PRIVATE
thirdparty_source_module_warnings
thirdparty_source_module_settings
)

set(public_header_path_list
Expand Down
2 changes: 1 addition & 1 deletion libraries/cmake/source/libdpkg/CMakeLists.txt
Expand Up @@ -133,7 +133,7 @@ function(libdpkgMain)
)

target_link_libraries(thirdparty_libdpkg PRIVATE
thirdparty_source_module_warnings
thirdparty_source_module_settings
)

target_compile_definitions(thirdparty_libdpkg PRIVATE
Expand Down
4 changes: 2 additions & 2 deletions libraries/cmake/source/libelfin/CMakeLists.txt
Expand Up @@ -30,7 +30,7 @@ function(libelfinElf)
)

target_link_libraries(thirdparty_libelfin_elf PRIVATE
thirdparty_source_module_warnings
thirdparty_source_module_settings
)

# The original package built for Buck was built installing
Expand Down Expand Up @@ -85,7 +85,7 @@ function(libelfinDwarf)
)

target_link_libraries(thirdparty_libelfin_dwarf PRIVATE
thirdparty_source_module_warnings
thirdparty_source_module_settings
)

# The original package built for Buck was built installing
Expand Down
2 changes: 1 addition & 1 deletion libraries/cmake/source/libgcrypt/CMakeLists.txt
Expand Up @@ -200,7 +200,7 @@ function(libgcryptMain)
)

target_link_libraries(thirdparty_libgcrypt PRIVATE
thirdparty_source_module_warnings
thirdparty_source_module_settings
)

target_include_directories(thirdparty_libgcrypt PRIVATE
Expand Down
2 changes: 1 addition & 1 deletion libraries/cmake/source/libgpg-error/CMakeLists.txt
Expand Up @@ -40,7 +40,7 @@ function(libgpgerrorMain)
)

target_link_libraries(thirdparty_libgpg-error PRIVATE
thirdparty_source_module_warnings
thirdparty_source_module_settings
)

target_include_directories(thirdparty_libgpg-error PRIVATE
Expand Down
2 changes: 1 addition & 1 deletion libraries/cmake/source/libiptables/CMakeLists.txt
Expand Up @@ -35,7 +35,7 @@ function(generateLibiptc)
)

target_link_libraries(thirdparty_libiptc PRIVATE
thirdparty_source_module_warnings
thirdparty_source_module_settings
)

target_include_directories(thirdparty_libiptc PRIVATE
Expand Down
2 changes: 1 addition & 1 deletion libraries/cmake/source/libmagic/CMakeLists.txt
Expand Up @@ -55,7 +55,7 @@ function(libmagicMain)
)

target_link_libraries(thirdparty_libmagic PRIVATE
thirdparty_source_module_warnings
thirdparty_source_module_settings
)

target_include_directories(thirdparty_libmagic PRIVATE
Expand Down
4 changes: 2 additions & 2 deletions libraries/cmake/source/librdkafka/CMakeLists.txt
Expand Up @@ -96,7 +96,7 @@ function(generateLibrdkafka)
)

target_link_libraries(thirdparty_librdkafka_c PRIVATE
thirdparty_source_module_warnings
thirdparty_source_module_settings
)

target_include_directories(thirdparty_librdkafka_c PRIVATE
Expand Down Expand Up @@ -138,7 +138,7 @@ function(generateLibrdkafkaxx)
)

target_link_libraries(thirdparty_librdkafka_cxx PRIVATE
thirdparty_source_module_warnings
thirdparty_source_module_settings
)

target_include_directories(thirdparty_librdkafka_cxx PRIVATE
Expand Down
2 changes: 1 addition & 1 deletion libraries/cmake/source/librpm/CMakeLists.txt
Expand Up @@ -138,7 +138,7 @@ function(librpmMain)
)

target_link_libraries(thirdparty_librpm PRIVATE
thirdparty_source_module_warnings
thirdparty_source_module_settings
)

target_include_directories(thirdparty_librpm PRIVATE
Expand Down
2 changes: 1 addition & 1 deletion libraries/cmake/source/libudev/CMakeLists.txt
Expand Up @@ -62,7 +62,7 @@ function(libudevMain)
)

target_link_libraries(thirdparty_libudev PRIVATE
thirdparty_source_module_warnings
thirdparty_source_module_settings
)

target_include_directories(thirdparty_libudev PRIVATE
Expand Down
2 changes: 1 addition & 1 deletion libraries/cmake/source/libxml2/CMakeLists.txt
Expand Up @@ -67,7 +67,7 @@ function(libxml2Main)
)

target_link_libraries(thirdparty_libxml2 PRIVATE
thirdparty_source_module_warnings
thirdparty_source_module_settings
)

target_include_directories(thirdparty_libxml2 PRIVATE
Expand Down
2 changes: 1 addition & 1 deletion libraries/cmake/source/linenoise-ng/CMakeLists.txt
Expand Up @@ -19,7 +19,7 @@ function(linenoisengMain)
)

target_link_libraries(thirdparty_linenoise-ng PRIVATE
thirdparty_source_module_warnings
thirdparty_source_module_settings
)

target_include_directories(thirdparty_linenoise-ng PRIVATE
Expand Down
4 changes: 2 additions & 2 deletions libraries/cmake/source/lldpd/CMakeLists.txt
Expand Up @@ -47,7 +47,7 @@ function(generateLibevent)
)

target_link_libraries(thirdparty_libevent PRIVATE
thirdparty_source_module_warnings
thirdparty_source_module_settings
)

target_include_directories(thirdparty_libevent PRIVATE
Expand Down Expand Up @@ -162,7 +162,7 @@ function(generateLiblldpd)
)

target_link_libraries(thirdparty_lldpd PRIVATE
thirdparty_source_module_warnings
thirdparty_source_module_settings
)

target_include_directories(thirdparty_lldpd PRIVATE
Expand Down

0 comments on commit da0b237

Please sign in to comment.