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
This commit is contained in:
Joerg-Christian Boehme 2018-09-22 12:02:05 +02:00 committed by GitHub
parent d292d65ca8
commit a7f9ebe116
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 17 deletions

View File

@ -112,7 +112,7 @@ endif()
if(ENABLE_DATA_POSTGRESQL) if(ENABLE_DATA_POSTGRESQL)
find_package(PostgreSQL REQUIRED) find_package(PostgreSQL REQUIRED)
else() else()
find_package(PostgreSQL QUIET) find_package(PostgreSQL)
endif() endif()
if(POSTGRESQL_FOUND) if(POSTGRESQL_FOUND)
@ -440,25 +440,13 @@ install(
Devel 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 "CMake ${CMAKE_VERSION} successfully configured ${PROJECT_NAME} using ${CMAKE_GENERATOR} generator")
message(STATUS "Installation target path: ${CMAKE_INSTALL_PREFIX}") message(STATUS "Installation target path: ${CMAKE_INSTALL_PREFIX}")
message(STATUS "C_FLAGS: =${CMAKE_C_FLAGS}") string(TOUPPER "${CMAKE_BUILD_TYPE}" BUILD_TYPE)
message(STATUS "CMAKE_C_FLAGS_DEBUG:=${CMAKE_C_FLAGS_DEBUG}") message(STATUS "[cmake] build type: ${CMAKE_BUILD_TYPE}")
message(STATUS "CMAKE_C_FLAGS_RELEASE:=${CMAKE_C_FLAGS_RELEASE}") message(STATUS "[cmake] build with cxx flags: ${CMAKE_CXX_FLAGS_${BUILD_TYPE}} ${CMAKE_CXX_FLAGS}")
message(STATUS "CMAKE_C_FLAGS_MINSIZEREL:=${CMAKE_C_FLAGS_MINSIZEREL}") message(STATUS "[cmake] build with c flags: ${CMAKE_C_FLAGS_${BUILD_TYPE}} ${CMAKE_C_FLAGS}")
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}")
foreach(component ${Poco_COMPONENTS}) foreach(component ${Poco_COMPONENTS})
message(STATUS "Building: ${component}") message(STATUS "Building: ${component}")

View File

@ -204,6 +204,9 @@ POCO_INSTALL(Foundation)
POCO_GENERATE_PACKAGE(Foundation) POCO_GENERATE_PACKAGE(Foundation)
if (ENABLE_TESTS) 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(samples)
add_subdirectory(testsuite) add_subdirectory(testsuite)
endif () endif ()