mirror of
https://gitee.com/an-tao/drogon.git
synced 2024-11-30 02:37:57 +08:00
Make shared linking possible, use option instead of set for CMake (#315)
This commit is contained in:
parent
fd6df92bbc
commit
832c6cb48d
@ -2,7 +2,22 @@ cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
project(drogon CXX)
|
||||
|
||||
add_library(${PROJECT_NAME} STATIC)
|
||||
option(BUILD_CTL "Build drogon_ctl" ON)
|
||||
option(BUILD_EXAMPLES "Build examples" ON)
|
||||
option(BUILD_ORM "Build orm" ON)
|
||||
option(LIBPQ_BATCH_MODE "Use batch mode for libpq" ON)
|
||||
option(BUILD_DROGON_SHARED "Build drogon as a shared lib" OFF)
|
||||
|
||||
if(BUILD_DROGON_SHARED)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
|
||||
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
|
||||
if("${isSystemDir}" STREQUAL "-1")
|
||||
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
|
||||
endif("${isSystemDir}" STREQUAL "-1")
|
||||
add_library(${PROJECT_NAME} SHARED)
|
||||
else()
|
||||
add_library(${PROJECT_NAME} STATIC)
|
||||
endif()
|
||||
|
||||
set(DROGON_MAJOR_VERSION 1)
|
||||
set(DROGON_MINOR_VERSION 0)
|
||||
@ -80,7 +95,7 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules/)
|
||||
# jsoncpp
|
||||
find_package(Jsoncpp REQUIRED)
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC ${JSONCPP_INCLUDE_DIRS})
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE ${JSONCPP_LIBRARIES})
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC ${JSONCPP_LIBRARIES})
|
||||
list(APPEND INCLUDE_DIRS_FOR_DYNAMIC_VIEW ${JSONCPP_INCLUDE_DIRS})
|
||||
message(STATUS "jsoncpp inc path:" ${JSONCPP_INCLUDE_DIRS})
|
||||
|
||||
@ -171,14 +186,6 @@ else()
|
||||
lib/src/ssl_funcs/Sha1.cc)
|
||||
endif()
|
||||
|
||||
if(NOT BUILD_ORM)
|
||||
set(BUILD_ORM TRUE CACHE BOOL INTERNAL)
|
||||
endif()
|
||||
|
||||
if(NOT LIBPQ_BATCH_MODE)
|
||||
set(LIBPQ_BATCH_MODE TRUE CACHE BOOL INTERNAL)
|
||||
endif()
|
||||
|
||||
if(BUILD_ORM)
|
||||
# find postgres
|
||||
find_package(PostgreSQL)
|
||||
@ -254,18 +261,10 @@ add_custom_command(TARGET makeVersion
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
VERBATIM)
|
||||
|
||||
if(NOT BUILD_EXAMPLES)
|
||||
set(BUILD_EXAMPLES TRUE CACHE BOOL INTERNAL)
|
||||
endif()
|
||||
|
||||
if(BUILD_EXAMPLES)
|
||||
add_subdirectory(examples)
|
||||
endif()
|
||||
|
||||
if(NOT BUILD_CTL)
|
||||
set(BUILD_CTL TRUE CACHE BOOL INTERNAL)
|
||||
endif()
|
||||
|
||||
if(BUILD_CTL)
|
||||
add_subdirectory(drogon_ctl)
|
||||
endif()
|
||||
@ -369,7 +368,8 @@ endif()
|
||||
|
||||
install(TARGETS ${PROJECT_NAME}
|
||||
EXPORT DrogonTargets
|
||||
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib)
|
||||
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib
|
||||
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib)
|
||||
|
||||
set(DROGON_HEADERS
|
||||
lib/inc/drogon/Attribute.h
|
||||
|
Loading…
Reference in New Issue
Block a user