Skip to content

Commit

Permalink
CMake Install support
Browse files Browse the repository at this point in the history
Added multi-game support for CMake (which specific mohaa game this build will be for)
  • Loading branch information
L committed Jan 29, 2023
1 parent e2a226f commit c661925
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,28 +58,50 @@ if(WIN32)
)
endif()

if(TARGET_GAME_TYPE)
if(TARGET_GAME_TYPE EQUAL 1)
set(TARGET_BASE_SUFFIX "ta")
elseif(TARGET_GAME_TYPE EQUAL 2)
set(TARGET_BASE_SUFFIX "tt")
else()
set(TARGET_BASE_SUFFIX)
message(SEND_ERROR "Invalid game type. Game type can be 0, 1 or 2")
endif()
else()
set(TARGET_BASE_SUFFIX)
set(TARGET_GAME_TYPE 0)
endif()

set(TARGET_BASE_GAME "main${TARGET_BASE_SUFFIX}")

add_compile_definitions(_CRT_SECURE_NO_WARNINGS)

IF(${CMAKE_C_COMPILER_ARCHITECTURE_ID} STREQUAL "x64") # for desktop
set(TARGET_SUFFIX "x64")
set(TARGET_ARCH_SUFFIX "x64")
ELSE(${CMAKE_C_COMPILER_ARCHITECTURE_ID} STREQUAL "x86") # for tx2
set(TARGET_SUFFIX "x86")
set(TARGET_ARCH_SUFFIX "x86")
ENDIF()

add_library(fgame SHARED ${SOURCES_SHARED} ${SOURCES_GAME})
target_compile_definitions(fgame PRIVATE GAME_DLL ARCHIVE_SUPPORTED)
target_compile_definitions(fgame PRIVATE GAME_DLL ARCHIVE_SUPPORTED TARGET_GAME_TYPE=${TARGET_GAME_TYPE})
target_compile_options(fgame PUBLIC "/showIncludes")
target_include_directories(fgame PUBLIC "code/qcommon" "code/script" "code/game")
set_target_properties(fgame PROPERTIES OUTPUT_NAME "game${TARGET_SUFFIX}")

set_target_properties(fgame PROPERTIES OUTPUT_NAME "game${TARGET_ARCH_SUFFIX}")
set_target_properties(fgame PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${TARGET_BASE_GAME})

add_executable(omohaaded ${SOURCES_SHARED} ${SOURCES_EXECUTABLE} ${SOURCES_SKEL} ${SOURCES_SERVER} ${SOURCES_PLATFORM_SPECIFIC} "code/null/null_client.c" "code/null/null_input.c" "code/null/null_snddma.c" "code/sys/sys_main.c" "code/sys/con_log.c")
set_property(TARGET omohaaded PROPERTY CXX_STANDARD 11)
target_compile_features(omohaaded PUBLIC cxx_constexpr)
target_compile_definitions(omohaaded PRIVATE NO_SCRIPTENGINE DEDICATED)
target_compile_definitions(omohaaded PRIVATE NO_SCRIPTENGINE DEDICATED TARGET_GAME_TYPE=${TARGET_GAME_TYPE})
target_include_directories(omohaaded PUBLIC "code/qcommon" "code/script" "code/server" "code/SDL2/include")
set_target_properties(omohaaded PROPERTIES OUTPUT_NAME "omohaaded${TARGET_SUFFIX}")
set_target_properties(omohaaded PROPERTIES OUTPUT_NAME "omohaaded${TARGET_BASE_SUFFIX}${TARGET_ARCH_SUFFIX}")

if(WIN32)
target_link_libraries(omohaaded wsock32 ws2_32)
target_link_libraries(omohaaded winmm)
endif()

INSTALL(TARGETS fgame DESTINATION $<CONFIG>/bin/${TARGET_BASE_GAME})
INSTALL(TARGETS omohaaded DESTINATION $<CONFIG>/bin)

0 comments on commit c661925

Please sign in to comment.