Add ENABLE_EXPORTS property in cmake configuration files (#375)

This commit is contained in:
An Tao 2020-03-05 22:03:41 +08:00 committed by GitHub
parent 56817978e6
commit ebb8b7b70a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions

View File

@ -14,22 +14,22 @@ endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
add_executable([[ProjectName]] main.cc)
add_executable(${PROJECT_NAME} main.cc)
##########
# If you include the drogon source code locally in your project, use this method to add drogon
# add_subdirectory(drogon)
# target_link_libraries([[ProjectName]] PRIVATE drogon)
# target_link_libraries(${PROJECT_NAME} PRIVATE drogon)
##########
find_package(Drogon CONFIG REQUIRED)
target_link_libraries([[ProjectName]] PRIVATE Drogon::Drogon)
target_link_libraries(${PROJECT_NAME} PRIVATE Drogon::Drogon)
if(CMAKE_CXX_STANDARD LESS 17)
#With C++14, use boost to support any and string_view
message(STATUS "use c++14")
find_package(Boost 1.61.0 REQUIRED)
target_include_directories([[ProjectName]] PRIVATE ${Boost_INCLUDE_DIRS})
target_include_directories(${PROJECT_NAME} PRIVATE ${Boost_INCLUDE_DIRS})
else()
message(STATUS "use c++17")
endif()
@ -52,5 +52,8 @@ foreach(cspFile ${SCP_LIST})
set(VIEWSRC ${VIEWSRC} ${classname}.cc)
endforeach()
target_include_directories([[ProjectName]] PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/models)
target_sources([[ProjectName]] PRIVATE ${SRC_DIR} ${CTL_SRC} ${FILTER_SRC} ${VIEWSRC} ${PLUGIN_SRC} ${MODEL_SRC})
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/models)
target_sources(${PROJECT_NAME} PRIVATE ${SRC_DIR} ${CTL_SRC} ${FILTER_SRC} ${VIEWSRC} ${PLUGIN_SRC} ${MODEL_SRC})
################################
# uncomment the following line for dynamically loading views
#set_property(TARGET ${PROJECT_NAME} PROPERTY ENABLE_EXPORTS ON)

View File

@ -73,3 +73,4 @@ set_property(TARGET ${example_targets}
PROPERTY CXX_STANDARD ${DROGON_CXX_STANDARD})
set_property(TARGET ${example_targets} PROPERTY CXX_STANDARD_REQUIRED ON)
set_property(TARGET ${example_targets} PROPERTY CXX_EXTENSIONS OFF)
set_property(TARGET webapp PROPERTY ENABLE_EXPORTS ON)