Skip to content
Snippets Groups Projects
Commit b0f020ff authored by Lukas Güldenstein's avatar Lukas Güldenstein
Browse files

Build docs with cmake

parent 72e9a24d
No related branches found
No related tags found
No related merge requests found
......@@ -6,20 +6,22 @@ set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Protobuf
find_package(Protobuf REQUIRED)
include_directories(${Protobuf_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${TARGET_NAME}.proto)
# Botan2 via PkgConfig
find_package(PkgConfig)
pkg_check_modules(BOTAN2 REQUIRED botan-2)
# LevelDB
find_path(
LEVELDB_INCLUDE_DIR
NAMES leveldb/db.h
DOC "leveldb include dir"
)
find_library(
LEVELDB_LIBRARY
NAMES leveldb
......@@ -28,24 +30,57 @@ find_library(
set(LEVELDB_INCLUDE_DIRS ${LEVELDB_INCLUDE_DIR})
set(LEVELDB_LIBRARIES ${LEVELDB_LIBRARY})
find_package(Doxygen REQUIRED doxygen dot)
# Threads
find_package(Threads REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
# CXXOPTS
add_subdirectory(extern/cxxopts)
# Common Sources for both executables
set(COMMON_SRCS
src/game.cpp
${PROTO_SRCS}
${PROTO_HDRS}
)
set(COMMON_LIBS
${Protobuf_LIBRARIES}
${BOTAN2_LIBRARIES}
${BOTAN2_LDFLAGS}
cxxopts
)
# Docs
option(BUILD_DOC "Build documentation" ON)
# check if Doxygen is installed
find_package(Doxygen)
if(DOXYGEN_FOUND)
# set input and output files
set(DOXYGEN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile)
message("Doxygen build started")
# note the option ALL which allows to build the docs together with the application
add_custom_target(doc_doxygen ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_FILE}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM)
else(DOXYGEN_FOUND)
message("Doxygen need to be installed to generate the doxygen documentation")
endif(DOXYGEN_FOUND)
# Server
set(server_sources src/server_main.cpp src/server.cpp ${COMMON_SRCS})
add_executable(${TARGET_NAME}_server ${server_sources})
target_link_libraries(${TARGET_NAME}_server ${Protobuf_LIBRARIES})
target_link_libraries(${TARGET_NAME}_server ${BOTAN2_LIBRARIES} ${BOTAN2_LDFLAGS})
target_link_libraries(${TARGET_NAME}_server ${COMMON_LIBS})
# target_link_libraries(${TARGET_NAME}_server ${Protobuf_LIBRARIES})
# target_link_libraries(${TARGET_NAME}_server ${BOTAN2_LIBRARIES} ${BOTAN2_LDFLAGS})
# target_link_libraries(${TARGET_NAME}_server cxxopts)
target_link_libraries(${TARGET_NAME}_server ${LEVELDB_LIBRARIES})
target_link_libraries(${TARGET_NAME}_server cxxopts)
target_include_directories(
${TARGET_NAME}_server PRIVATE
${CMAKE_SOURCE_DIR}/src
......@@ -54,11 +89,15 @@ target_include_directories(
${LEVELDB_INCLUDE_DIRS}
cxxopts
)
# Client
set(client_sources src/client_main.cpp src/client.cpp ${COMMON_SRCS})
add_executable(${TARGET_NAME}_client ${client_sources})
target_link_libraries(${TARGET_NAME}_client ${Protobuf_LIBRARIES})
target_link_libraries(${TARGET_NAME}_client ${BOTAN2_LIBRARIES} ${BOTAN2_LDFLAGS})
target_link_libraries(${TARGET_NAME}_client cxxopts)
target_link_libraries(${TARGET_NAME}_client ${COMMON_LIBS})
# target_link_libraries(${TARGET_NAME}_client ${Protobuf_LIBRARIES})
# target_link_libraries(${TARGET_NAME}_client ${BOTAN2_LIBRARIES} ${BOTAN2_LDFLAGS})
# target_link_libraries(${TARGET_NAME}_client cxxopts)
target_include_directories(
${TARGET_NAME}_client PRIVATE
${CMAKE_SOURCE_DIR}/src
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment