1
0
Fork 0
mirror of https://github.com/KingDuckZ/dindexer.git synced 2024-11-29 01:33:46 +00:00

Fix libpqtypes as external project.

Note: due to a bug in cmake/ninja, this change introduces
problems when building with ninja. See:
https://cmake.org/Bug/view.php?id=15256
This commit is contained in:
King_DuckZ 2015-12-27 03:09:08 +00:00
parent d8f3578497
commit a91e75829f
3 changed files with 40 additions and 21 deletions

View file

@ -4,7 +4,7 @@ project("${bare_name}-if" VERSION 0.1.3 LANGUAGES CXX C)
list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules)
include(GetGitRevisionDescription)
include(ExternalProject)
include(Buildlibpqtypes)
option(DINDEXER_DEBUG_CFG_FILE "Enable to set the config file path to the build path" OFF)
option(DINDEXER_WITH_MEDIA_AUTODETECT "Enable code that tries to autodetect the media type and sets --type automatically" ON)
@ -27,6 +27,7 @@ message(STATUS "Config file set to \"${DINDEXER_CONFIG_FILE}\"")
find_package(Boost 1.53.0 REQUIRED COMPONENTS program_options)
find_package(PostgreSQL 8.3 REQUIRED)
find_package(YamlCpp 0.5.1 REQUIRED)
import_libpqtypes_project("${PostgreSQL_INCLUDE_DIRS}")
add_library(${PROJECT_NAME} INTERFACE)
add_library(${bare_name}-inc INTERFACE)
@ -48,25 +49,6 @@ target_include_directories(${bare_name}-inc
INTERFACE ${CMAKE_SOURCE_DIR}/include
)
string(REPLACE ";" " -I" pqtypes_inc_dirs "-I${PostgreSQL_INCLUDE_DIRS}")
set(pqtypes_name "libpqtypes-1.5.1")
set(pqtypes_prefix ${CMAKE_CURRENT_BINARY_DIR}/lib/${pqtypes_name})
ExternalProject_Add(pqtypes_working
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/${pqtypes_name}
PREFIX lib/${pqtypes_name}
CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/lib/${pqtypes_name}/configure --prefix ${pqtypes_prefix} "CPPFLAGS=${pqtypes_inc_dirs}" --quiet
BUILD_COMMAND ${MAKE}
BUILD_IN_SOURCE 0
INSTALL_DIR ${pqtypes_prefix}
)
add_library(pqtypes SHARED IMPORTED)
set_target_properties(pqtypes PROPERTIES
IMPORTED_LOCATION ${pqtypes_prefix}/lib/libpqtypes.so
IMPORTED_LINK_INTERFACE_LANGUAGES C
#INCLUDE_DIRECTORIES ${pqtypes_prefix}/include
)
add_subdirectory(src/scan)
add_subdirectory(src/pq)
add_subdirectory(src/main)

View file

@ -0,0 +1,37 @@
include(ExternalProject)
function (import_libpqtypes_project PostgreSQL_INCLUDE_DIRS)
#find_path(libpqtypes_base_path NAMES src/libpqtypes.h PATHS ${CMAKE_CURRENT_SOURCE_DIR}/lib NO_DEFAULT_PATH)
file(GLOB_RECURSE libpqtypes_base_path "lib/**libpqtypes.h")
string(REPLACE ";" " -I" libpqtypes_inc_dirs "-I${PostgreSQL_INCLUDE_DIRS}")
string(REPLACE "src/libpqtypes.h" "" libpqtypes_base_path "${libpqtypes_base_path}")
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}" libpqtypes_prefix "${libpqtypes_base_path}")
string(REGEX REPLACE "/$" "" libpqtypes_prefix "${libpqtypes_prefix}")
ExternalProject_Add(ext_project_pqtypes
DOWNLOAD_COMMAND ""
SOURCE_DIR ${libpqtypes_base_path}
PREFIX ${libpqtypes_prefix}
CONFIGURE_COMMAND ${libpqtypes_base_path}/configure --prefix ${libpqtypes_prefix} "CPPFLAGS=${libpqtypes_inc_dirs}" --quiet
BUILD_COMMAND ${MAKE}
BUILD_IN_SOURCE 0
)
add_library(pqtypes SHARED IMPORTED)
add_dependencies(pqtypes ext_project_pqtypes)
set_target_properties(pqtypes PROPERTIES
IMPORTED_LOCATION ${libpqtypes_prefix}/lib/libpqtypes.so
)
if(EXISTS "${libpqtypes_base_path}/configure.ac")
file(STRINGS "${libpqtypes_base_path}/configure.ac" libpqtypes_version_str REGEX "^AC_INIT[\t ]*\\([\t ]*libpqtypes[\t ]*,[\t ]*[0-9].*$")
string(REGEX REPLACE "^AC_INIT[\t ]*\\([\t ]*libpqtypes[\t ]*,[\t ]*([^,]+)[\t ]*,.*$" "\\1" libpqtypes_version "${libpqtypes_version_str}")
unset(libpqtypes_version_str)
message(STATUS "libpqtypes v${libpqtypes_version} found")
endif()
set(libpqtypes_INCLUDE_DIRS "${libpqtypes_prefix}/include" PARENT_SCOPE)
unset(libpqtypes_prefix)
unset(libpqtypes_inc_dirs)
endfunction()

View file

@ -7,7 +7,7 @@ add_library(${PROJECT_NAME} STATIC
)
target_include_directories(${PROJECT_NAME}
PRIVATE ${pqtypes_prefix}/include
PRIVATE ${libpqtypes_INCLUDE_DIRS}
)
target_link_libraries(${PROJECT_NAME}
PRIVATE ${bare_name}-if