This is an automated email from the ASF dual-hosted git repository. astitcher pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/qpid-proton.git
The following commit(s) were added to refs/heads/master by this push: new c5367f5 PROTON-2048: Avoid recompiling some source files - The source of proton-core used to be compiled twice Once for qpid-proton-core and once for qpid-proton - Now use a cmake object library to only compile once - The test_main of catch2 is very template heavy and takes a lot of time on small machines to compile. It was previously recompiled for each of the C tests, now we use a cmake object library. - This reduces some CI build times by approx 20% c5367f5 is described below commit c5367f5307dae7909149875cca6b314603a33858 Author: Andrew Stitcher <astitc...@apache.org> AuthorDate: Fri May 10 12:54:00 2019 -0400 PROTON-2048: Avoid recompiling some source files - The source of proton-core used to be compiled twice Once for qpid-proton-core and once for qpid-proton - Now use a cmake object library to only compile once - The test_main of catch2 is very template heavy and takes a lot of time on small machines to compile. It was previously recompiled for each of the C tests, now we use a cmake object library. - This reduces some CI build times by approx 20% --- c/CMakeLists.txt | 23 ++++++++++++++--------- c/tests/CMakeLists.txt | 5 ++++- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/c/CMakeLists.txt b/c/CMakeLists.txt index effb96b..b6617d8 100644 --- a/c/CMakeLists.txt +++ b/c/CMakeLists.txt @@ -443,8 +443,19 @@ set(qpid-proton-core-src ${qpid-proton-include-generated} ) -add_library (qpid-proton-core SHARED ${qpid-proton-core-src}) -add_dependencies (qpid-proton-core generated_c_files) +add_library (qpid-proton-core-objects OBJECT ${qpid-proton-core-src}) +add_dependencies (qpid-proton-core-objects generated_c_files) +set_target_properties(qpid-proton-core-objects PROPERTIES POSITION_INDEPENDENT_CODE ON) +target_compile_definitions(qpid-proton-core-objects PRIVATE qpid_proton_core_EXPORTS) + +# Can't use target_link_libraries() because cmake 2.8.12 doesn't allow object libraries as the first param +# otherwise for cmake 3.9 and on this would be: +# target_link_libraries (qpid-proton-core-objects ${SSL_LIB} ${SASL_LIB} ${TIME_LIB} ${PLATFORM_LIBS}) +target_compile_definitions(qpid-proton-core-objects PRIVATE $<TARGET_PROPERTY:qpid-proton-core,COMPILE_DEFINITIONS>) +target_compile_options (qpid-proton-core-objects PRIVATE $<TARGET_PROPERTY:qpid-proton-core,COMPILE_OPTIONS>) +target_include_directories(qpid-proton-core-objects PRIVATE $<TARGET_PROPERTY:qpid-proton-core,INCLUDE_DIRECTORIES>) + +add_library (qpid-proton-core SHARED $<TARGET_OBJECTS:qpid-proton-core-objects>) target_link_libraries (qpid-proton-core ${SSL_LIB} ${SASL_LIB} ${TIME_LIB} ${PLATFORM_LIBS}) set_target_properties (qpid-proton-core PROPERTIES @@ -458,12 +469,6 @@ if (BUILD_STATIC_LIBS) endif(BUILD_STATIC_LIBS) set(qpid-proton-src - # Proton Core - ${qpid-proton-core} - ${qpid-proton-layers} - ${qpid-proton-platform} - ${qpid-proton-include} - ${qpid-proton-include-generated} # Proactor ${qpid-proton-proactor} # Proton Reactor/Messenger @@ -472,7 +477,7 @@ set(qpid-proton-src ${qpid-proton-include-extra} ) -add_library (qpid-proton SHARED ${qpid-proton-src}) +add_library (qpid-proton SHARED $<TARGET_OBJECTS:qpid-proton-core-objects> ${qpid-proton-src}) target_link_libraries (qpid-proton LINK_PRIVATE ${SSL_LIB} ${SASL_LIB} ${TIME_LIB} ${PLATFORM_LIBS} ${PROACTOR_LIBS}) set_target_properties (qpid-proton PROPERTIES diff --git a/c/tests/CMakeLists.txt b/c/tests/CMakeLists.txt index 3642112..ae75d2e 100644 --- a/c/tests/CMakeLists.txt +++ b/c/tests/CMakeLists.txt @@ -37,8 +37,11 @@ endif() # Tests for each library are combined in a single executable. if (CMAKE_CXX_COMPILER) + + add_library(test_main OBJECT test_main.cpp) + macro(add_c_test exe) - add_executable(${exe} test_main.cpp pn_test.cpp ${ARGN}) + add_executable(${exe} $<TARGET_OBJECTS:test_main> pn_test.cpp ${ARGN}) set_target_properties(${exe} PROPERTIES COMPILE_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_WARNING_FLAGS}") add_test(NAME ${exe} COMMAND ${test_env} ${TEST_EXE_PREFIX_CMD} $<TARGET_FILE:${exe}>) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org