Skip to content

Commit 1c04b1a

Browse files
authored
Fix some compatibility issues introduced by std::filesystem or boost::filesystem (#947)
1 parent 895ab63 commit 1c04b1a

5 files changed

Lines changed: 27 additions & 11 deletions

File tree

cmake/templates/DrogonConfig.cmake.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ find_dependency(MySQL)
2929
endif()
3030
if(@Boost_FOUND@)
3131
find_dependency(Boost)
32+
find_package(Boost COMPONENTS filesystem system)
3233
endif()
3334
if(@Brotli_FOUND@)
3435
find_dependency(Brotli)

drogon_ctl/create_project.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ static void newTestMainFile(std::ofstream &mainFile)
7272
auto templ = DrTemplateBase::newTemplate("test_main");
7373
mainFile << templ->genText();
7474
}
75+
static void newTestCmakeFile(std::ofstream &testCmakeFile,
76+
const std::string &projectName)
77+
{
78+
HttpViewData data;
79+
data.insert("ProjectName", projectName);
80+
auto templ = DrTemplateBase::newTemplate("test_cmake");
81+
testCmakeFile << templ->genText(data);
82+
}
7583
void create_project::createProject(const std::string &projectName)
7684
{
7785
#ifdef _WIN32
@@ -115,4 +123,6 @@ void create_project::createProject(const std::string &projectName)
115123
newModelConfigFile(modelConfigFile);
116124
std::ofstream testMainFile("test/test_main.cc", std::ofstream::out);
117125
newTestMainFile(testMainFile);
126+
std::ofstream testCmakeFile("test/CMakeLists.txt", std::ofstream::out);
127+
newTestCmakeFile(testCmakeFile, projectName);
118128
}

drogon_ctl/templates/cmake.csp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,24 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
1818
set(CMAKE_CXX_EXTENSIONS OFF)
1919

2020
add_executable(${PROJECT_NAME} main.cc)
21-
add_executable(${PROJECT_NAME}_test)
2221

2322
# ##############################################################################
2423
# If you include the drogon source code locally in your project, use this method
2524
# to add drogon
2625
# add_subdirectory(drogon)
2726
# target_link_libraries(${PROJECT_NAME} PRIVATE drogon)
28-
# target_link_libraries(${PROJECT_NAME}_test PRIVATE drogon)
2927
#
3028
# and comment out the following lines
3129
find_package(Drogon CONFIG REQUIRED)
3230
target_link_libraries(${PROJECT_NAME} PRIVATE Drogon::Drogon)
33-
target_link_libraries(${PROJECT_NAME}_test PRIVATE Drogon::Drogon)
3431

3532
# ##############################################################################
3633

3734
if (CMAKE_CXX_STANDARD LESS 17)
3835
# With C++14, use boost to support any, string_view and filesystem
3936
message(STATUS "use c++14")
4037
find_package(Boost 1.61.0 REQUIRED)
41-
find_package(Boost 1.61.0 REQUIRED COMPONENTS filesystem)
4238
target_link_libraries(${PROJECT_NAME} PUBLIC Boost::boost)
43-
target_link_libraries(${PROJECT_NAME} PUBLIC Boost::filesystem)
4439
elseif (CMAKE_CXX_STANDARD LESS 20)
4540
message(STATUS "use c++17")
4641
else ()
@@ -74,8 +69,4 @@ target_sources(${PROJECT_NAME}
7469

7570
# ##############################################################################
7671

77-
aux_source_directory(test TEST_SRC)
78-
target_sources(${PROJECT_NAME}_test
79-
PRIVATE
80-
${TEST_SRC})
81-
ParseAndAddDrogonTests(${PROJECT_NAME}_test)
72+
add_subdirectory(test)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
cmake_minimum_required(VERSION 3.5)
2+
project([[ProjectName]]_test CXX)
3+
4+
add_executable(${PROJECT_NAME} test_main.cc)
5+
6+
# ##############################################################################
7+
# If you include the drogon source code locally in your project, use this method
8+
# to add drogon
9+
# target_link_libraries(${PROJECT_NAME}_test PRIVATE drogon)
10+
#
11+
# and comment out the following lines
12+
target_link_libraries(${PROJECT_NAME} PRIVATE Drogon::Drogon)
13+
14+
ParseAndAddDrogonTests(${PROJECT_NAME})

trantor

0 commit comments

Comments
 (0)