cmake: reorganize project structure

isolation_bkp/dynres
Dominik Madarász 2021-01-19 10:44:43 +01:00
parent d744f37ac4
commit 52d61551a9
9 changed files with 30 additions and 58 deletions

View File

@ -1,5 +1,6 @@
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
project(eco2d) project(eco2d)
include(cmake/utils.cmake)
set(CMAKE_C_STANDARD 11) set(CMAKE_C_STANDARD 11)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/)
@ -11,5 +12,8 @@ include_directories(eco2d-cli code/vendors code/common)
include_directories(eco2d-client code/vendors code/common) include_directories(eco2d-client code/vendors code/common)
include_directories(eco2d-server code/vendors code/vendors/flecs code/common) include_directories(eco2d-server code/vendors code/vendors/flecs code/common)
add_subdirectory(code/common)
add_subdirectory(code/vendors)
add_subdirectory(code/apps/client) add_subdirectory(code/apps/client)
add_subdirectory(code/apps/server) add_subdirectory(code/apps/server)

View File

@ -0,0 +1,9 @@
function(link_system_libs target_name)
if (WIN32)
target_link_libraries(${target_name} winmm)
elseif (APPLE)
target_link_libraries(${target_name} pthread m dl)
elseif (UNIX)
target_link_libraries(${target_name} pthread m dl atomic)
endif()
endfunction()

View File

@ -25,14 +25,7 @@ add_library(client-common STATIC
source/main.c source/main.c
header/network.h header/network.h
header/platform.h
header/game.h header/game.h
../../common/signal_handling.c
../../common/signal_handling.h
../../common/assets.h
../../common/assets.c
) )
add_executable(eco2d-client add_executable(eco2d-client
@ -43,17 +36,11 @@ add_executable(eco2d-cli
source/platform_text.c source/platform_text.c
) )
include_directories(header/) set(LIBS client-common cwpack eco2d-common)
target_link_libraries(eco2d-client raylib client-common)
target_link_libraries(eco2d-cli client-common)
if (WIN32) include_directories(header/)
target_link_libraries(eco2d-cli winmm) target_link_libraries(eco2d-client raylib ${LIBS})
target_link_libraries(eco2d-client winmm) target_link_libraries(eco2d-cli ${LIBS})
elseif (APPLE)
target_link_libraries(eco2d-cli pthread m dl) link_system_libs(eco2d-cli)
target_link_libraries(eco2d-client pthread m dl) link_system_libs(eco2d-client)
elseif (UNIX)
target_link_libraries(eco2d-cli pthread m dl atomic)
target_link_libraries(eco2d-client pthread m dl atomic)
endif()

View File

@ -18,44 +18,8 @@ add_executable(eco2d-server
header/components/physics.h header/components/physics.h
header/components/general.h header/components/general.h
header/components/controllers.h header/components/controllers.h
../../common/signal_handling.c
../../common/signal_handling.h
../../common/assets.h
../../common/assets.c
../../vendors/cwpack/cwpack.c
../../vendors/cwpack/cwpack.h
../../vendors/flecs/flecs.c
../../vendors/flecs/flecs.h
../../vendors/flecs/flecs_meta.c
../../vendors/flecs/flecs_meta.h
../../vendors/flecs/flecs_json.h
../../vendors/flecs/flecs_json.c
../../vendors/flecs/flecs_rest.h
../../vendors/flecs/flecs_rest.c
../../vendors/flecs/flecs_monitor.h
../../vendors/flecs/flecs_monitor.c
../../vendors/flecs/flecs_player.h
../../vendors/flecs/flecs_player.c
../../vendors/flecs/flecs_dash.h
../../vendors/flecs/flecs_dash.c
../../vendors/flecs/flecs_components_http.h
../../vendors/flecs/flecs_components_http.c
../../vendors/flecs/flecs_systems_civetweb.h
../../vendors/flecs/flecs_systems_civetweb.c
../../vendors/flecs/flecs_os_api_posix.h
../../vendors/flecs/flecs_os_api_posix.c
) )
include_directories(eco2d-server header) include_directories(eco2d-server header)
target_link_libraries(eco2d-server eco2d-common flecs-bundle cwpack)
if (WIN32) link_system_libs(eco2d-server)
target_link_libraries(eco2d-server winmm)
elseif (APPLE)
target_link_libraries(eco2d-server pthread m dl)
elseif (UNIX)
target_link_libraries(eco2d-server pthread m dl atomic)
endif()

View File

@ -0,0 +1,2 @@
file(GLOB_RECURSE SRCS *.h *.c)
add_library(eco2d-common STATIC ${SRCS})

2
code/vendors/CMakeLists.txt vendored 100644
View File

@ -0,0 +1,2 @@
add_subdirectory(flecs)
add_subdirectory(cwpack)

View File

@ -0,0 +1,2 @@
file(GLOB SRCS *.h *.c)
add_library(cwpack STATIC ${SRCS})

View File

@ -0,0 +1,2 @@
file(GLOB SRCS *.c *.h)
add_library(flecs-bundle STATIC ${SRCS})