diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 90f05963..a6c25e61 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -78,7 +78,7 @@ jobs: CC: ${{ matrix.os.cc }} CXX: ${{ matrix.os.cxx }} VCPKG_ROOT: C:/vcpkg - run: cmake --preset ${{ matrix.os.preset }} -DBUILD_TESTING=ON -DENABLE_LOGGER=ON + run: cmake --preset ${{ matrix.os.preset }} -DBUILD_TESTING=ON -DENABLE_LOGGER=ON -DFORCE_PORTABLE_INSTALL=ON - name: Build ${{ matrix.build_type }} run: cmake --build --preset ${{ matrix.os.preset }} --config ${{ matrix.build_type }} --verbose @@ -86,8 +86,12 @@ jobs: - name: Run ${{ matrix.build_type }} Unittests run: ctest --preset ${{ matrix.os.preset }} -C ${{ matrix.build_type }} + - name: Local install + # There no cmake install presets so install in traditional way + run: cmake --install builds/${{ matrix.os.preset }}/ --config ${{ matrix.build_type }} + - name: Upload Artifacts uses: actions/upload-artifact@v4 with: name: Descent3_${{ matrix.build_type }}_${{ matrix.os.name }} - path: ${{ github.workspace }}/builds/${{ matrix.os.preset }}/Descent3/${{ matrix.build_type }}/ + path: ${{ github.workspace }}/builds/${{ matrix.os.preset }}/installed/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ea2b7e4..dd7f92fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,7 @@ project(Descent3 ) option(FORCE_COLORED_OUTPUT "Always produce ANSI-colored compiler warnings/errors (GCC/Clang only; esp. useful with ninja)." OFF) +option(FORCE_PORTABLE_INSTALL "Install all files into local directory defined by CMAKE_INSTALL_PREFIX" ON) option(ENABLE_LOGGER "Enable logging to the terminal" OFF) option(BUILD_TESTING "Enable testing. Requires GTest." OFF) @@ -31,6 +32,18 @@ if(FORCE_COLORED_OUTPUT) endif() endif() +include(GNUInstallDirs) +if(FORCE_PORTABLE_INSTALL) + set(CMAKE_INSTALL_BINDIR ".") + set(CMAKE_INSTALL_LIBDIR ".") + set(CMAKE_INSTALL_DATADIR ".") + set(CMAKE_INSTALL_DOCDIR ".") +endif() + +if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/installed" CACHE PATH "Default install path" FORCE) +endif() + if(CMAKE_CXX_BYTE_ORDER STREQUAL "BIG_ENDIAN") message(STATUS "Big Endian system detected.") add_compile_definitions("OUTRAGE_BIG_ENDIAN") @@ -63,14 +76,14 @@ add_custom_command( WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} ) +install(FILES README.md LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR}) + # rebuild version.hpp every time add_custom_target(get_git_hash ALL DEPENDS ${PROJECT_BINARY_DIR}/Descent3/d3_version.h ) if(UNIX) - set(D3_GAMEDIR "~/Descent3/") - add_compile_options("$<$:-Wno-multichar;${BITS};${EXTRA_CXX_FLAGS}>") add_compile_options("$<$:${BITS}>") diff --git a/Descent3/CMakeLists.txt b/Descent3/CMakeLists.txt index 5f43a0be..6ec0dd2f 100644 --- a/Descent3/CMakeLists.txt +++ b/Descent3/CMakeLists.txt @@ -303,6 +303,7 @@ target_link_libraries(Descent3 ${PLATFORM_LIBS}) target_include_directories(Descent3 PRIVATE ${PROJECT_BINARY_DIR}/lib) add_dependencies(Descent3 get_git_hash Direct_TCP_IP_Hog HogFull NetgamesDir) +install(TARGETS Descent3 RUNTIME) if(BUILD_TESTING) add_subdirectory(tests) diff --git a/netcon/lanclient/CMakeLists.txt b/netcon/lanclient/CMakeLists.txt index 9ff0a2fc..0eb1617d 100644 --- a/netcon/lanclient/CMakeLists.txt +++ b/netcon/lanclient/CMakeLists.txt @@ -21,3 +21,4 @@ add_custom_target(Direct_TCP_IP_Hog DEPENDS Direct_TCP_IP HogMaker COMMENT "Generate 'Direct TCP~IP.d3c'" ) +install(FILES "$/online/Direct TCP~IP.d3c" DESTINATION ${CMAKE_INSTALL_DATADIR}/online) diff --git a/netgames/anarchy/CMakeLists.txt b/netgames/anarchy/CMakeLists.txt index dfe1e84d..98a3d04e 100644 --- a/netgames/anarchy/CMakeLists.txt +++ b/netgames/anarchy/CMakeLists.txt @@ -9,3 +9,4 @@ set_target_properties(${NETGAME_MODULE} PROPERTIES PREFIX "") set_target_properties(${NETGAME_MODULE} PROPERTIES SUFFIX ".d3m") target_link_libraries(${NETGAME_MODULE} dmfc) +install(TARGETS "${NETGAME_MODULE}" DESTINATION ${CMAKE_INSTALL_LIBDIR}/netgames) diff --git a/netgames/coop/CMakeLists.txt b/netgames/coop/CMakeLists.txt index c53e6a83..651052fa 100644 --- a/netgames/coop/CMakeLists.txt +++ b/netgames/coop/CMakeLists.txt @@ -9,3 +9,4 @@ set_target_properties(${NETGAME_MODULE} PROPERTIES PREFIX "") set_target_properties(${NETGAME_MODULE} PROPERTIES SUFFIX ".d3m") target_link_libraries(${NETGAME_MODULE} dmfc) +install(TARGETS "${NETGAME_MODULE}" DESTINATION ${CMAKE_INSTALL_LIBDIR}/netgames) diff --git a/netgames/ctf/CMakeLists.txt b/netgames/ctf/CMakeLists.txt index 22dca2f6..f3008f2f 100644 --- a/netgames/ctf/CMakeLists.txt +++ b/netgames/ctf/CMakeLists.txt @@ -9,3 +9,4 @@ set_target_properties(${NETGAME_MODULE} PROPERTIES PREFIX "") set_target_properties(${NETGAME_MODULE} PROPERTIES SUFFIX ".d3m") target_link_libraries(${NETGAME_MODULE} dmfc) +install(TARGETS "${NETGAME_MODULE}" DESTINATION ${CMAKE_INSTALL_LIBDIR}/netgames) diff --git a/netgames/entropy/CMakeLists.txt b/netgames/entropy/CMakeLists.txt index 20fa91c7..77868a27 100644 --- a/netgames/entropy/CMakeLists.txt +++ b/netgames/entropy/CMakeLists.txt @@ -9,3 +9,4 @@ set_target_properties(${NETGAME_MODULE} PROPERTIES PREFIX "") set_target_properties(${NETGAME_MODULE} PROPERTIES SUFFIX ".d3m") target_link_libraries(${NETGAME_MODULE} dmfc) +install(TARGETS "${NETGAME_MODULE}" DESTINATION ${CMAKE_INSTALL_LIBDIR}/netgames) diff --git a/netgames/hoard/CMakeLists.txt b/netgames/hoard/CMakeLists.txt index 8db7428b..4c8d9d4b 100644 --- a/netgames/hoard/CMakeLists.txt +++ b/netgames/hoard/CMakeLists.txt @@ -9,3 +9,4 @@ set_target_properties(${NETGAME_MODULE} PROPERTIES PREFIX "") set_target_properties(${NETGAME_MODULE} PROPERTIES SUFFIX ".d3m") target_link_libraries(${NETGAME_MODULE} dmfc) +install(TARGETS "${NETGAME_MODULE}" DESTINATION ${CMAKE_INSTALL_LIBDIR}/netgames) diff --git a/netgames/hyperanarchy/CMakeLists.txt b/netgames/hyperanarchy/CMakeLists.txt index 0095e3c0..c75cfef9 100644 --- a/netgames/hyperanarchy/CMakeLists.txt +++ b/netgames/hyperanarchy/CMakeLists.txt @@ -9,3 +9,4 @@ set_target_properties(${NETGAME_MODULE} PROPERTIES PREFIX "") set_target_properties(${NETGAME_MODULE} PROPERTIES SUFFIX ".d3m") target_link_libraries(${NETGAME_MODULE} dmfc) +install(TARGETS "${NETGAME_MODULE}" DESTINATION ${CMAKE_INSTALL_LIBDIR}/netgames) diff --git a/netgames/monsterball/CMakeLists.txt b/netgames/monsterball/CMakeLists.txt index 4ff811da..76392a3d 100644 --- a/netgames/monsterball/CMakeLists.txt +++ b/netgames/monsterball/CMakeLists.txt @@ -9,3 +9,4 @@ set_target_properties(${NETGAME_MODULE} PROPERTIES PREFIX "") set_target_properties(${NETGAME_MODULE} PROPERTIES SUFFIX ".d3m") target_link_libraries(${NETGAME_MODULE} dmfc) +install(TARGETS "${NETGAME_MODULE}" DESTINATION ${CMAKE_INSTALL_LIBDIR}/netgames) diff --git a/netgames/roboanarchy/CMakeLists.txt b/netgames/roboanarchy/CMakeLists.txt index f310598e..18268c7e 100644 --- a/netgames/roboanarchy/CMakeLists.txt +++ b/netgames/roboanarchy/CMakeLists.txt @@ -9,3 +9,4 @@ set_target_properties(${NETGAME_MODULE} PROPERTIES PREFIX "") set_target_properties(${NETGAME_MODULE} PROPERTIES SUFFIX ".d3m") target_link_libraries(${NETGAME_MODULE} dmfc) +install(TARGETS "${NETGAME_MODULE}" DESTINATION ${CMAKE_INSTALL_LIBDIR}/netgames) diff --git a/netgames/tanarchy/CMakeLists.txt b/netgames/tanarchy/CMakeLists.txt index 1c737a4b..74c1732d 100644 --- a/netgames/tanarchy/CMakeLists.txt +++ b/netgames/tanarchy/CMakeLists.txt @@ -9,3 +9,4 @@ set_target_properties(${NETGAME_MODULE} PROPERTIES PREFIX "") set_target_properties(${NETGAME_MODULE} PROPERTIES SUFFIX ".d3m") target_link_libraries(${NETGAME_MODULE} dmfc) +install(TARGETS "${NETGAME_MODULE}" DESTINATION ${CMAKE_INSTALL_LIBDIR}/netgames) diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index 5f3fe654..25229309 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -95,6 +95,9 @@ add_custom_target(HogFull COMMENT "Generate fullhog/d3-${HOG_NAME}.hog" ) +# Place file next to Descent3 executable on installation +install(FILES "$/d3-${HOG_NAME}.hog" DESTINATION ${CMAKE_INSTALL_DATADIR}) + # FIXME: there may be only one d3-linux.hog, need deal with demo somehow. # add_custom_target(HogLinuxDemo # COMMAND $