|
| 1 | +cmake_minimum_required(VERSION 3.0) |
| 2 | + |
| 3 | +project(ctf01d) |
| 4 | + |
| 5 | +include(${CMAKE_CURRENT_SOURCE_DIR}/src.wsjcpp/CMakeLists.txt) |
| 6 | + |
| 7 | +#### BEGIN_WSJCPP_APPEND |
| 8 | +#### END_WSJCPP_APPEND |
| 9 | + |
| 10 | +set(CMAKE_CXX_STANDARD 11) |
| 11 | +set(EXECUTABLE_OUTPUT_PATH ${ctf01d_SOURCE_DIR}) |
| 12 | +# set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") |
| 13 | + |
| 14 | +# Sources |
| 15 | + |
| 16 | +# include header dirs |
| 17 | +list (APPEND WSJCPP_INCLUDE_DIRS "src") |
| 18 | +list (APPEND WSJCPP_INCLUDE_DIRS "src/argument_processors") |
| 19 | +list (APPEND WSJCPP_INCLUDE_DIRS "src/checker") |
| 20 | +list (APPEND WSJCPP_INCLUDE_DIRS "src/scoreboard") |
| 21 | +list (APPEND WSJCPP_INCLUDE_DIRS "src/storages") |
| 22 | +list (APPEND WSJCPP_INCLUDE_DIRS "src/storages/file") |
| 23 | +list (APPEND WSJCPP_INCLUDE_DIRS "src/service_locator") |
| 24 | +list (APPEND WSJCPP_INCLUDE_DIRS "src/http_handlers") |
| 25 | + |
| 26 | +# argument processors |
| 27 | +list (APPEND WSJCPP_SOURCES "./src/argument_processors/argument_processor_check.h") |
| 28 | +list (APPEND WSJCPP_SOURCES "./src/argument_processors/argument_processor_check.cpp") |
| 29 | +list (APPEND WSJCPP_SOURCES "./src/argument_processors/argument_processor_clean.h") |
| 30 | +list (APPEND WSJCPP_SOURCES "./src/argument_processors/argument_processor_clean.cpp") |
| 31 | +list (APPEND WSJCPP_SOURCES "./src/argument_processors/argument_processor_ctf01d_main.h") |
| 32 | +list (APPEND WSJCPP_SOURCES "./src/argument_processors/argument_processor_ctf01d_main.cpp") |
| 33 | +list (APPEND WSJCPP_SOURCES "./src/argument_processors/argument_processor_start.h") |
| 34 | +list (APPEND WSJCPP_SOURCES "./src/argument_processors/argument_processor_start.cpp") |
| 35 | +list (APPEND WSJCPP_SOURCES "./src/argument_processors/argument_processor_version.h") |
| 36 | +list (APPEND WSJCPP_SOURCES "./src/argument_processors/argument_processor_version.cpp") |
| 37 | +list (APPEND WSJCPP_SOURCES "./src/argument_processors/argument_processor_web_test.h") |
| 38 | +list (APPEND WSJCPP_SOURCES "./src/argument_processors/argument_processor_web_test.cpp") |
| 39 | + |
| 40 | +# employees |
| 41 | +list (APPEND WSJCPP_SOURCES "./src/service_locator/employ_team_logos.h") |
| 42 | +list (APPEND WSJCPP_SOURCES "./src/service_locator/employ_team_logos.cpp") |
| 43 | +list (APPEND WSJCPP_SOURCES "./src/service_locator/employ_flags.h") |
| 44 | +list (APPEND WSJCPP_SOURCES "./src/service_locator/employ_flags.cpp") |
| 45 | +list (APPEND WSJCPP_SOURCES "./src/service_locator/employ_scoreboard.h") |
| 46 | +list (APPEND WSJCPP_SOURCES "./src/service_locator/employ_scoreboard.cpp") |
| 47 | +list (APPEND WSJCPP_SOURCES "./src/service_locator/employ_config.h") |
| 48 | +list (APPEND WSJCPP_SOURCES "./src/service_locator/employ_config.cpp") |
| 49 | + |
| 50 | +# checker |
| 51 | +list (APPEND WSJCPP_SOURCES "src/checker/dorunchecker.h") |
| 52 | +list (APPEND WSJCPP_SOURCES "src/checker/dorunchecker.cpp") |
| 53 | +list (APPEND WSJCPP_SOURCES "src/checker/service_checker_thread.h") |
| 54 | +list (APPEND WSJCPP_SOURCES "src/checker/service_checker_thread.cpp") |
| 55 | + |
| 56 | +# http_handlers |
| 57 | +list (APPEND WSJCPP_SOURCES "src/http_handlers/http_handler_api_v1.h") |
| 58 | +list (APPEND WSJCPP_SOURCES "src/http_handlers/http_handler_api_v1.cpp") |
| 59 | +list (APPEND WSJCPP_SOURCES "src/http_handlers/http_handler_web_folder.h") |
| 60 | +list (APPEND WSJCPP_SOURCES "src/http_handlers/http_handler_web_folder.cpp") |
| 61 | +list (APPEND WSJCPP_SOURCES "./src/http_handlers/light_web_http_handler_team_logo.h") |
| 62 | +list (APPEND WSJCPP_SOURCES "./src/http_handlers/light_web_http_handler_team_logo.cpp") |
| 63 | + |
| 64 | +# scoreboard |
| 65 | +list (APPEND WSJCPP_SOURCES "src/scoreboard/scoreboard.cpp") |
| 66 | +list (APPEND WSJCPP_SOURCES "src/scoreboard/scoreboard.h") |
| 67 | + |
| 68 | +# storages |
| 69 | +list (APPEND WSJCPP_SOURCES "src/storages/storages.h") |
| 70 | +list (APPEND WSJCPP_SOURCES "src/storages/storages.cpp") |
| 71 | + |
| 72 | +# file storage |
| 73 | +# list (APPEND WSJCPP_SOURCES "src/storages/file/file_storage.h") |
| 74 | +# list (APPEND WSJCPP_SOURCES "src/storages/file/file_storage.cpp") |
| 75 | + |
| 76 | +# main |
| 77 | +list (APPEND WSJCPP_SOURCES "src/main.cpp") |
| 78 | + |
| 79 | + |
| 80 | +############################ |
| 81 | +##### mysql storage |
| 82 | +list (APPEND WSJCPP_INCLUDE_DIRS "src/storages/mysql") |
| 83 | +list (APPEND WSJCPP_SOURCES "src/storages/mysql/mysql_storage.h") |
| 84 | +list (APPEND WSJCPP_SOURCES "src/storages/mysql/mysql_storage.cpp") |
| 85 | + |
| 86 | +# Find and make sure the system have the header file |
| 87 | +find_path(MYSQL_HEADER mysql/mysql.h) |
| 88 | +if(MYSQL_HEADER STREQUAL "MYSQL_HEADER-NOTFOUND") |
| 89 | + message(FATAL_ERROR "Could not find the mysql/mysql.h header file: apt install libmysqlclient-dev") |
| 90 | +endif() |
| 91 | + |
| 92 | +include(FindPkgConfig) |
| 93 | +pkg_check_modules(LIBMYSQLCLIENT REQUIRED mysqlclient) |
| 94 | + |
| 95 | +foreach(FLAG ${LIBMYSQLCLIENT_CFLAGS_OTHER}) |
| 96 | + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAG}") |
| 97 | +endforeach() |
| 98 | + |
| 99 | +list (APPEND WSJCPP_INCLUDE_DIRS ${LIBMYSQLCLIENT_LIBRARY_DIRS}) |
| 100 | +list (APPEND WSJCPP_LIBRARIES ${LIBMYSQLCLIENT_LIBRARIES}) |
| 101 | + |
| 102 | +##### |
| 103 | +############################ |
| 104 | + |
| 105 | +# ZLIB |
| 106 | +find_package( ZLIB REQUIRED ) |
| 107 | +if ( ZLIB_FOUND ) |
| 108 | + list (APPEND WSJCPP_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS}) |
| 109 | + include_directories( ${ZLIB_INCLUDE_DIRS} ) |
| 110 | + list (APPEND WSJCPP_LIBRARIES ${ZLIB_LIBRARIES}) |
| 111 | +endif( ZLIB_FOUND ) |
| 112 | + |
| 113 | +# LIBPNG |
| 114 | +find_package(PNG REQUIRED) |
| 115 | +if (NOT PNG_FOUND) |
| 116 | + message(FATAL_ERROR "You don't seem to have libpng development libraries installed (apt isntall libpng-dev)") |
| 117 | +else () |
| 118 | + list (APPEND WSJCPP_INCLUDE_DIRS ${PNG_INCLUDE_DIR}) |
| 119 | + list (APPEND WSJCPP_LIBRARIES ${PNG_LIBRARY}) |
| 120 | +endif () |
| 121 | + |
| 122 | +# CURL |
| 123 | +FIND_PACKAGE(CURL) |
| 124 | +IF(CURL_FOUND) |
| 125 | + list (APPEND WSJCPP_INCLUDE_DIRS ${CURL_INCLUDE_DIR}) |
| 126 | + list (APPEND WSJCPP_LIBRARIES ${CURL_LIBRARIES}) |
| 127 | +ELSE(CURL_FOUND) |
| 128 | + MESSAGE(FATAL_ERROR "Could not find the CURL library and development files.") |
| 129 | +ENDIF(CURL_FOUND) |
| 130 | + |
| 131 | +include_directories(${WSJCPP_INCLUDE_DIRS}) |
| 132 | + |
| 133 | +add_executable (ctf01d ${WSJCPP_SOURCES}) |
| 134 | + |
| 135 | +target_link_libraries(ctf01d -lpthread ${WSJCPP_LIBRARIES} ) |
| 136 | + |
| 137 | +install( |
| 138 | + TARGETS |
| 139 | + ctf01d |
| 140 | + RUNTIME DESTINATION |
| 141 | + ${CMAKE_INSTALL_PREFIX}/bin |
| 142 | +) |
| 143 | + |
| 144 | + |
0 commit comments