diff --git a/.appveyor.yml b/.appveyor.yml index ced09abe..f9915d63 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -38,3 +38,8 @@ init: build_script: - ctest -VV -S cmake/ctest/script_ci.ctest + +after_build: + - cd "%APPVEYOR_BUILD_FOLDER%\build" + - cpack -C Release -G TXZ + - appveyor PushArtifact OpenRW-%APPVEYOR_REPO_COMMIT:~0,8%.tar.xz diff --git a/CMakeCPack.cmake b/CMakeCPack.cmake new file mode 100644 index 00000000..9b63b965 --- /dev/null +++ b/CMakeCPack.cmake @@ -0,0 +1,17 @@ +set(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "OpenRW 'Open ReWrite' is an un-official open source recreation of the classic Grand Theft Auto III game executable") +set(CPACK_PACKAGE_VENDOR "openrw") + +# FIXME: better description of the project +set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING") +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING") +string(SUBSTRING "${GIT_SHA1}" 0 8 GIT_SHA1_SHORT) +set(CPACK_PACKAGE_VERSION "${GIT_SHA1_SHORT}") +set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}") +set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${GIT_SHA1_SHORT}") + +set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${GIT_SHA1_SHORT}") + +# set(CPACK_PROJECT_CONFIG_FILE "${CMAKE_CURRENT_SOURCE_DIR}/CMakeCPackOptions.cmake") + +include(CPack) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d48276e..ea10eeab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,12 +2,19 @@ cmake_minimum_required(VERSION 3.2.2) project(OpenRW) +include(GNUInstallDirs) + # Read the configuration arguments include("${PROJECT_SOURCE_DIR}/cmake_options.cmake") # Create a rw_interface TARGET that holds all compiler options include("${PROJECT_SOURCE_DIR}/cmake_configure.cmake") +# Include git hash in source +include(GetGitRevisionDescription) +get_git_head_revision(GIT_REFSPEC GIT_SHA1) +message(STATUS "Building ${CMAKE_PROJECT_NAME} GIT SHA1: ${GIT_SHA1}") + set(OpenGL_GL_PREFERENCE GLVND) find_package(OpenGL REQUIRED) find_package(OpenAL REQUIRED) @@ -20,10 +27,6 @@ if(CHECK_CLANGTIDY) find_package(ClangTidy REQUIRED) endif() -# Include git hash in source -include(GetGitRevisionDescription) -get_git_head_revision(GIT_REFSPEC GIT_SHA1) - add_subdirectory(rwlib) add_subdirectory(rwengine) add_subdirectory(rwgame) @@ -38,13 +41,13 @@ if(BUILD_TESTS) endif() # Copy the license to the install directory -if(CMAKE_SYSTEM_NAME MATCHES "Linux|FreeBSD") - install(FILES COPYING - DESTINATION "${DOC_DIR}" - ) -endif() +install(FILES COPYING + DESTINATION "${CMAKE_INSTALL_DOCDIR}" + ) # Copy the license to the build directory (for CI) file(COPY COPYING DESTINATION "${PROJECT_BINARY_DIR}" ) + +include(CMakeCPack.cmake) diff --git a/cmake_options.cmake b/cmake_options.cmake index 5deaf2a2..ecce5f62 100644 --- a/cmake_options.cmake +++ b/cmake_options.cmake @@ -14,9 +14,6 @@ set_property(CACHE FAILED_CHECK_ACTION PROPERTY STRINGS "IGNORE" "ABORT" "BREAKP set(FILESYSTEM_LIBRARY "BOOST" CACHE STRING "Which filesystem library to use") set_property(CACHE FILESYSTEM_LIBRARY PROPERTY STRINGS "CXX17" "CXXTS" "BOOST") -set(BIN_DIR "bin" CACHE STRING "Prefix subdirectory to put the binaries in.") -set(DOC_DIR "share/doc/openrw" CACHE STRING "Prefix subdirectory to put the documentation in.") - if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: Debug Release") endif() diff --git a/rwengine/CMakeLists.txt b/rwengine/CMakeLists.txt index ddcf29e1..3fbe13e6 100644 --- a/rwengine/CMakeLists.txt +++ b/rwengine/CMakeLists.txt @@ -159,3 +159,10 @@ target_include_directories(rwengine ) openrw_target_apply_options(TARGET rwengine) + +if(BUILD_SHARED_LIBS) + install(TARGETS rwengine + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ) +endif() diff --git a/rwgame/CMakeLists.txt b/rwgame/CMakeLists.txt index 45e41842..cf871476 100644 --- a/rwgame/CMakeLists.txt +++ b/rwgame/CMakeLists.txt @@ -65,4 +65,6 @@ target_link_libraries(rwgame openrw_target_apply_options(TARGET rwgame) -install(TARGETS rwgame RUNTIME DESTINATION "${BIN_DIR}") +install(TARGETS rwgame + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + ) diff --git a/rwlib/CMakeLists.txt b/rwlib/CMakeLists.txt index 29963f55..e249bb92 100644 --- a/rwlib/CMakeLists.txt +++ b/rwlib/CMakeLists.txt @@ -63,4 +63,16 @@ target_link_libraries(rwlib OpenGL::GL ) +set_target_properties(rwlib + PROPERTIES + OUTPUT_NAME rw + ) + openrw_target_apply_options(TARGET rwlib) + +if(BUILD_SHARED_LIBS) + install(TARGETS rwlib + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ) +endif() diff --git a/rwviewer/CMakeLists.txt b/rwviewer/CMakeLists.txt index 26c08c3b..48700743 100644 --- a/rwviewer/CMakeLists.txt +++ b/rwviewer/CMakeLists.txt @@ -35,5 +35,5 @@ target_link_libraries(rwviewer openrw_target_apply_options(TARGET rwviewer) install(TARGETS rwviewer - RUNTIME DESTINATION "${BIN_DIR}" + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" ) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b54889f1..99ec944a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -114,3 +114,7 @@ else() TIMEOUT 300 ) endif() + +install(TARGETS rwtests + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + )