From f28ff134922ad3647f8f866fda7bb47134a72f80 Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Fri, 15 Jul 2016 20:02:42 +0100 Subject: [PATCH] travis is not getting the -fPIC right for pq it seems. Also make top-level cmake file default to Release if no build type is given. --- CMakeLists.txt | 9 +++++++++ src/pq/CMakeLists.txt | 10 +++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d5565c0..6b7880e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,15 @@ set(CPACK_DEBIAN_PACKAGE_MAINTAINER "King_DuckZ") set(CPACK_PACKAGE_NAME "${bare_name}") set(CPACK_STRIP_FILES ON) +#Make sure this is either Debug or Release +set(DINDEXER_SUPPORTED_BUILD_TYPES "Debug;Release") +list(FIND DINDEXER_SUPPORTED_BUILD_TYPES "${CMAKE_BUILD_TYPE}" build_type_index) +if (${build_type_index} LESS 0) + message(STATUS "Forcing build type to Release") + set(CMAKE_BUILD_TYPE "Release") +endif() +unset(build_type_index) + include(GetGitRevisionDescription) include(Buildlibpqtypes) include(gccversion) diff --git a/src/pq/CMakeLists.txt b/src/pq/CMakeLists.txt index d164d80..6dbf43e 100644 --- a/src/pq/CMakeLists.txt +++ b/src/pq/CMakeLists.txt @@ -1,8 +1,5 @@ project(${bare_name}-pq CXX) -set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fPIC") -set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fPIC") - add_library(${PROJECT_NAME} STATIC connection.cpp databaseexception.cpp @@ -30,3 +27,10 @@ target_compile_features(${PROJECT_NAME} # RUNTIME DESTINATION bin # ARCHIVE DESTINATION lib/static #) + +#Allow linking with .so +#see https://cmake.org/pipermail/cmake/2007-May/014350.html +#and http://stackoverflow.com/questions/6093547/what-do-r-x86-64-32s-and-r-x86-64-64-relocation-mean/6093910#6093910 +if (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" ) + set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-fPIC") +endif()