From a7f9ebe1161f4939ef8b61a84e66c2676c51b263 Mon Sep 17 00:00:00 2001 From: Joerg-Christian Boehme Date: Sat, 22 Sep 2018 12:02:05 +0200 Subject: [PATCH] Fix static build in cmake (#2455) * Fix cmake build issue when poco build as static lib with enabled tests * Cleanup compile flags output in cmake * Some minor improvements in cmake --- CMakeLists.txt | 22 +++++----------------- Foundation/CMakeLists.txt | 3 +++ 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7df655ddc..cd08ea606 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -112,7 +112,7 @@ endif() if(ENABLE_DATA_POSTGRESQL) find_package(PostgreSQL REQUIRED) else() - find_package(PostgreSQL QUIET) + find_package(PostgreSQL) endif() if(POSTGRESQL_FOUND) @@ -440,25 +440,13 @@ install( Devel ) -# in tree build settings -#configure_file(PocoBuildTreeSettings.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/PocoBuildTreeSettings.cmake @ONLY) - - message(STATUS "CMake ${CMAKE_VERSION} successfully configured ${PROJECT_NAME} using ${CMAKE_GENERATOR} generator") message(STATUS "Installation target path: ${CMAKE_INSTALL_PREFIX}") -message(STATUS "C_FLAGS: =${CMAKE_C_FLAGS}") -message(STATUS "CMAKE_C_FLAGS_DEBUG:=${CMAKE_C_FLAGS_DEBUG}") -message(STATUS "CMAKE_C_FLAGS_RELEASE:=${CMAKE_C_FLAGS_RELEASE}") -message(STATUS "CMAKE_C_FLAGS_MINSIZEREL:=${CMAKE_C_FLAGS_MINSIZEREL}") -message(STATUS "CMAKE_C_FLAGS_RELWITHDEBINFO:=${CMAKE_C_FLAGS_RELWITHDEBINFO}") -message(STATUS "") -message(STATUS "") -message(STATUS "CXX_FLAGS:=${CMAKE_CXX_FLAGS}") -message(STATUS "CMAKE_CXX_FLAGS_DEBUG:=${CMAKE_CXX_FLAGS_DEBUG}") -message(STATUS "CMAKE_CXX_FLAGS_RELEASE:=${CMAKE_CXX_FLAGS_RELEASE}") -message(STATUS "CMAKE_CXX_FLAGS_MINSIZEREL:=${CMAKE_CXX_FLAGS_MINSIZEREL}") -message(STATUS "CMAKE_CXX_FLAGS_RELWITHDEBINFO:=${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") +string(TOUPPER "${CMAKE_BUILD_TYPE}" BUILD_TYPE) +message(STATUS "[cmake] build type: ${CMAKE_BUILD_TYPE}") +message(STATUS "[cmake] build with cxx flags: ${CMAKE_CXX_FLAGS_${BUILD_TYPE}} ${CMAKE_CXX_FLAGS}") +message(STATUS "[cmake] build with c flags: ${CMAKE_C_FLAGS_${BUILD_TYPE}} ${CMAKE_C_FLAGS}") foreach(component ${Poco_COMPONENTS}) message(STATUS "Building: ${component}") diff --git a/Foundation/CMakeLists.txt b/Foundation/CMakeLists.txt index 3d286c7a7..2aad07bd1 100644 --- a/Foundation/CMakeLists.txt +++ b/Foundation/CMakeLists.txt @@ -204,6 +204,9 @@ POCO_INSTALL(Foundation) POCO_GENERATE_PACKAGE(Foundation) if (ENABLE_TESTS) + if(POCO_STATIC) + set_property(TARGET Foundation PROPERTY POSITION_INDEPENDENT_CODE ON) # This is needed to build TestLibrary.so as shared. + endif() add_subdirectory(samples) add_subdirectory(testsuite) endif ()