Skip to content

Commit

Permalink
Fix some compatibility issues introduced by std::filesystem or boost:…
Browse files Browse the repository at this point in the history
…:filesystem (#947)
  • Loading branch information
an-tao committed Jul 23, 2021
1 parent 895ab63 commit 1c04b1a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 11 deletions.
1 change: 1 addition & 0 deletions cmake/templates/DrogonConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ find_dependency(MySQL)
endif()
if(@Boost_FOUND@)
find_dependency(Boost)
find_package(Boost COMPONENTS filesystem system)
endif()
if(@Brotli_FOUND@)
find_dependency(Brotli)
Expand Down
10 changes: 10 additions & 0 deletions drogon_ctl/create_project.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ static void newTestMainFile(std::ofstream &mainFile)
auto templ = DrTemplateBase::newTemplate("test_main");
mainFile << templ->genText();
}
static void newTestCmakeFile(std::ofstream &testCmakeFile,
const std::string &projectName)
{
HttpViewData data;
data.insert("ProjectName", projectName);
auto templ = DrTemplateBase::newTemplate("test_cmake");
testCmakeFile << templ->genText(data);
}
void create_project::createProject(const std::string &projectName)
{
#ifdef _WIN32
Expand Down Expand Up @@ -115,4 +123,6 @@ void create_project::createProject(const std::string &projectName)
newModelConfigFile(modelConfigFile);
std::ofstream testMainFile("test/test_main.cc", std::ofstream::out);
newTestMainFile(testMainFile);
std::ofstream testCmakeFile("test/CMakeLists.txt", std::ofstream::out);
newTestCmakeFile(testCmakeFile, projectName);
}
11 changes: 1 addition & 10 deletions drogon_ctl/templates/cmake.csp
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,24 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

add_executable(${PROJECT_NAME} main.cc)
add_executable(${PROJECT_NAME}_test)

# ##############################################################################
# If you include the drogon source code locally in your project, use this method
# to add drogon
# add_subdirectory(drogon)
# target_link_libraries(${PROJECT_NAME} PRIVATE drogon)
# target_link_libraries(${PROJECT_NAME}_test PRIVATE drogon)
#
# and comment out the following lines
find_package(Drogon CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE Drogon::Drogon)
target_link_libraries(${PROJECT_NAME}_test PRIVATE Drogon::Drogon)

# ##############################################################################

if (CMAKE_CXX_STANDARD LESS 17)
# With C++14, use boost to support any, string_view and filesystem
message(STATUS "use c++14")
find_package(Boost 1.61.0 REQUIRED)
find_package(Boost 1.61.0 REQUIRED COMPONENTS filesystem)
target_link_libraries(${PROJECT_NAME} PUBLIC Boost::boost)
target_link_libraries(${PROJECT_NAME} PUBLIC Boost::filesystem)
elseif (CMAKE_CXX_STANDARD LESS 20)
message(STATUS "use c++17")
else ()
Expand Down Expand Up @@ -74,8 +69,4 @@ target_sources(${PROJECT_NAME}

# ##############################################################################

aux_source_directory(test TEST_SRC)
target_sources(${PROJECT_NAME}_test
PRIVATE
${TEST_SRC})
ParseAndAddDrogonTests(${PROJECT_NAME}_test)
add_subdirectory(test)
14 changes: 14 additions & 0 deletions drogon_ctl/templates/test_cmake.csp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
cmake_minimum_required(VERSION 3.5)
project([[ProjectName]]_test CXX)

add_executable(${PROJECT_NAME} test_main.cc)

# ##############################################################################
# If you include the drogon source code locally in your project, use this method
# to add drogon
# target_link_libraries(${PROJECT_NAME}_test PRIVATE drogon)
#
# and comment out the following lines
target_link_libraries(${PROJECT_NAME} PRIVATE Drogon::Drogon)

ParseAndAddDrogonTests(${PROJECT_NAME})
2 changes: 1 addition & 1 deletion trantor

0 comments on commit 1c04b1a

Please sign in to comment.