fixed multiple definition problem and added test to make sure it doesn't

happen again
This commit is contained in:
The-EDev 2022-02-23 06:00:00 +03:00
parent 603cf00b6b
commit 37940d2cc0
No known key found for this signature in database
GPG Key ID: 51C45DC0C413DCD9
5 changed files with 24 additions and 1 deletions

View File

@ -107,7 +107,7 @@ namespace crow
// should not add an item below this line: used for array count
};
const char* method_strings[] =
constexpr const char* method_strings[] =
{
"DELETE",
"GET",

View File

@ -17,6 +17,7 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
endif()
add_subdirectory(template)
add_subdirectory(multi_file)
if (CROW_ENABLE_SSL)
add_subdirectory(ssl)
endif()

View File

@ -0,0 +1,6 @@
project(test_multi_file)
file (GLOB_RECURSE SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
add_executable(${PROJECT_NAME} ${SRC})
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(${PROJECT_NAME} PUBLIC Crow::Crow)

15
tests/multi_file/main.cpp Normal file
View File

@ -0,0 +1,15 @@
// Test of a project containing more than 1 source file which includes Crow headers.
// The test succeeds if the project is linked successfully.
#include "crow.h"
int main()
{
crow::SimpleApp app;
CROW_ROUTE(app, "/")
([]() {
return "Hello, world!";
});
app.port(18080).run();
}

View File

@ -0,0 +1 @@
#include <crow.h>