Updated project structure:
CMake changes: - Replace text files containing paths to installation, with install commands - You can set paths as cache variable - Added new option INSTALL_AFTER_BUILD Code changes: - Revert the changes to allow usage for older versions of g2o (like 0.1.9) This change is only temporary, to publish the release module fo the older g2o versions.
This commit is contained in:
@@ -2,6 +2,11 @@ cmake_minimum_required(VERSION 3.17)
|
||||
|
||||
project(SqModule)
|
||||
|
||||
option(INSTALL_AFTER_BUILD "Run cmake --install separately for every target after each build. By default this option is set to OFF" ON)
|
||||
|
||||
set(GAME_PATH "" CACHE PATH "This option specifies the game location. It's only used for the installation step.")
|
||||
set(SERVER_PATH "" CACHE PATH "This option specifies the server location. It's only used for the installation step.")
|
||||
|
||||
file(GLOB SRC
|
||||
"dependencies/squirrel/include/*.h"
|
||||
"dependencies/sqrat/include/*.h"
|
||||
@@ -12,6 +17,8 @@ file(GLOB SRC
|
||||
"src/sqmain.cpp"
|
||||
)
|
||||
|
||||
add_subdirectory("dependencies/squirrel/squirrel")
|
||||
|
||||
add_library(SqModule SHARED ${SRC})
|
||||
target_precompile_headers(SqModule PRIVATE "src/pch.h")
|
||||
|
||||
@@ -24,20 +31,34 @@ target_include_directories(SqModule
|
||||
"dependencies/sqrat/include/"
|
||||
)
|
||||
|
||||
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.game.dir.txt")
|
||||
file(READ ".game.dir.txt" GAME_DIR)
|
||||
target_link_libraries(SqModule PRIVATE squirrel_static)
|
||||
|
||||
add_custom_command(TARGET SqModule
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:SqModule> ${GAME_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "[Post Build] $<TARGET_FILE_NAME:SqModule> copied to: ${GAME_DIR}")
|
||||
if (NOT ${GAME_PATH} STREQUAL "")
|
||||
install(TARGETS SqModule
|
||||
RUNTIME
|
||||
DESTINATION ${GAME_PATH}
|
||||
COMPONENT "clientModule"
|
||||
)
|
||||
|
||||
if(INSTALL_AFTER_BUILD)
|
||||
add_custom_command(TARGET SqModule
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} --install ${CMAKE_CURRENT_BINARY_DIR} --component "clientModule"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.server.dir.txt")
|
||||
file(READ ".server.dir.txt" SERVER_DIR)
|
||||
if (NOT ${SERVER_PATH} STREQUAL "")
|
||||
install(TARGETS SqModule
|
||||
RUNTIME
|
||||
DESTINATION ${SERVER_PATH}
|
||||
COMPONENT "serverModule"
|
||||
)
|
||||
|
||||
add_custom_command(TARGET SqModule
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:SqModule> ${SERVER_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "[Post Build] $<TARGET_FILE_NAME:SqModule> copied to: ${SERVER_DIR}")
|
||||
if(INSTALL_AFTER_BUILD)
|
||||
add_custom_command(TARGET SqModule
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} --install ${CMAKE_CURRENT_BINARY_DIR} --component "serverModule"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user