mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-30 08:27:50 +08:00
69 lines
2.3 KiB
CMake
69 lines
2.3 KiB
CMake
cmake_minimum_required(VERSION 3.5)
|
|
project(libpqxx VERSION 6.0.0 LANGUAGES CXX)
|
|
set(CMAKE_DEBUG_POSTFIX "D")
|
|
|
|
find_library(LIBPQD libpqd)
|
|
find_library(LIBPQ libpq)
|
|
find_path(LIBPQ_FE_H libpq-fe.h)
|
|
find_path(POSTGRES_EXT_H postgres_ext.h)
|
|
|
|
include(CheckIncludeFileCXX)
|
|
|
|
check_include_file_cxx(poll.h HAVE_POLL)
|
|
check_include_file_cxx(sys/select.h HAVE_SYS_SELECT_H)
|
|
check_include_file_cxx(sys/time.h HAVE_SYS_TIME_H)
|
|
check_include_file_cxx(sys/types.h HAVE_SYS_TYPES_H)
|
|
check_include_file_cxx(unistd.h HAVE_UNISTD_H)
|
|
|
|
include(CheckCXXSourceCompiles)
|
|
|
|
check_cxx_source_compiles("[[deprecated]] void f();
|
|
int main() { return 0; }" PQXX_HAVE_DEPRECATED)
|
|
check_cxx_source_compiles("#include <optional>
|
|
int main() { return std::optional<int>(0).value(); }" PQXX_HAVE_OPTIONAL)
|
|
check_cxx_source_compiles("#include <experimental/optional>
|
|
int main() { return std::experimental::optional<int>(0).value(); }" PQXX_HAVE_EXP_OPTIONAL)
|
|
|
|
configure_file(config-internal-compiler.h.in pqxx/config-internal-compiler.h)
|
|
configure_file(config-public-compiler.h.in pqxx/config-public-compiler.h)
|
|
|
|
file(GLOB SRCS "${PROJECT_SOURCE_DIR}/src/*.cxx")
|
|
|
|
if(BUILD_SHARED_LIBS)
|
|
set(TARGET libpqxx)
|
|
set(SHARED_DEFINITION -DPQXX_SHARED)
|
|
list(APPEND SRCS "${PROJECT_SOURCE_DIR}/win32/libpqxx.cxx")
|
|
else()
|
|
set(TARGET libpqxx_static)
|
|
set(SHARED_DEFINITION "")
|
|
endif()
|
|
|
|
add_library(${TARGET} ${SRCS})
|
|
target_compile_definitions(${TARGET} PRIVATE -DPQXX_INTERNAL -DNOMINMAX ${SHARED_DEFINITION})
|
|
target_include_directories(${TARGET} PRIVATE include ${LIBPQ_FE_H} ${POSTGRES_EXT_H} ${CMAKE_BINARY_DIR})
|
|
target_link_libraries(${TARGET} PRIVATE ws2_32)
|
|
if(LIBPQD AND LIBPQ)
|
|
target_link_libraries(${TARGET} PRIVATE debug ${LIBPQD} optimized ${LIBPQ})
|
|
elseif(LIBPQD)
|
|
target_link_libraries(${TARGET} PRIVATE ${LIBPQD})
|
|
else()
|
|
target_link_libraries(${TARGET} PRIVATE ${LIBPQ})
|
|
endif()
|
|
|
|
install(TARGETS ${TARGET}
|
|
RUNTIME DESTINATION bin
|
|
ARCHIVE DESTINATION lib
|
|
LIBRARY DESTINATION lib
|
|
)
|
|
install(DIRECTORY include/ DESTINATION include
|
|
CONFIGURATIONS Release
|
|
PATTERN "doc" EXCLUDE
|
|
PATTERN "*.am" EXCLUDE
|
|
PATTERN "*.in" EXCLUDE
|
|
PATTERN "*.template" EXCLUDE
|
|
)
|
|
install(DIRECTORY ${CMAKE_BINARY_DIR}/pqxx/ DESTINATION include/pqxx
|
|
CONFIGURATIONS Release
|
|
FILES_MATCHING PATTERN "*.h"
|
|
)
|