diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d48276e..3e33d9f9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.2.2) project(OpenRW) +include(GNUInstallDirs) + # Read the configuration arguments include("${PROJECT_SOURCE_DIR}/cmake_options.cmake") @@ -38,11 +40,9 @@ 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 diff --git a/cmake_options.cmake b/cmake_options.cmake index 5deaf2a2..b38bd331 100644 --- a/cmake_options.cmake +++ b/cmake_options.cmake @@ -14,8 +14,7 @@ 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.") +option(INSTALL_LIBS "Install rwengine libraries") if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: Debug Release") diff --git a/rwengine/CMakeLists.txt b/rwengine/CMakeLists.txt index ddcf29e1..48115ca5 100644 --- a/rwengine/CMakeLists.txt +++ b/rwengine/CMakeLists.txt @@ -159,3 +159,10 @@ target_include_directories(rwengine ) openrw_target_apply_options(TARGET rwengine) + +if(INSTALL_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..67862d61 100644 --- a/rwlib/CMakeLists.txt +++ b/rwlib/CMakeLists.txt @@ -64,3 +64,10 @@ target_link_libraries(rwlib ) openrw_target_apply_options(TARGET rwlib) + +if(INSTALL_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}" + )