cmake: make bin, lib and share directories configurable

This commit is contained in:
Sebastian Krzyszkowiak 2019-11-11 21:23:43 +01:00
parent ae2c483111
commit 5c9ebfdbdd
No known key found for this signature in database
GPG key ID: E8F235CF3BDBC3FF
4 changed files with 16 additions and 12 deletions

View file

@ -1,7 +1,7 @@
SET(DATADIR "${CMAKE_INSTALL_PREFIX}/share/${LIBSUPERDERPY_GAMENAME}/data")
SET(DATADIR "${CMAKE_INSTALL_PREFIX}/${SHARE_DIR}/${LIBSUPERDERPY_GAMENAME}/data")
if(APPLE)
SET(DATADIR "${CMAKE_INSTALL_PREFIX}/bin/${LIBSUPERDERPY_GAMENAME}.app/Contents/Resources/data") #OMG NASTY
SET(DATADIR "${CMAKE_INSTALL_PREFIX}/${BIN_DIR}/${LIBSUPERDERPY_GAMENAME}.app/Contents/Resources/data") #OMG NASTY
endif(APPLE)
add_subdirectory(icons)

View file

@ -1,6 +1,6 @@
set(EXECUTABLE ${LIBSUPERDERPY_GAMENAME})
set(CMAKE_INSTALL_RPATH "\$ORIGIN/../lib/${LIBSUPERDERPY_GAMENAME}:\$ORIGIN/gamestates:\$ORIGIN:\$ORIGIN/../lib:\$ORIGIN/lib:\$ORIGIN/bin")
set(CMAKE_INSTALL_RPATH "\$ORIGIN/../${LIB_DIR}/${LIBSUPERDERPY_GAMENAME}:\$ORIGIN/gamestates:\$ORIGIN:\$ORIGIN/../${LIB_DIR}:\$ORIGIN/${LIB_DIR}:\$ORIGIN/${BIN_DIR}")
if(MINGW)
# resource compilation for MinGW
@ -21,7 +21,7 @@ target_link_libraries(${EXECUTABLE} "lib${LIBSUPERDERPY_GAMENAME}")
if (APPLE)
target_link_libraries(${EXECUTABLE} ${ALLEGRO5_MAIN_LIBRARIES})
endif(APPLE)
install(TARGETS ${EXECUTABLE} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
install(TARGETS ${EXECUTABLE} DESTINATION ${CMAKE_INSTALL_PREFIX}/${BIN_DIR})
if (LIBSUPERDERPY_STATIC_COMMON)
add_library("lib${LIBSUPERDERPY_GAMENAME}" STATIC ${SHARED_SRC_LIST})
@ -31,7 +31,7 @@ endif(LIBSUPERDERPY_STATIC_COMMON)
set_target_properties("lib${LIBSUPERDERPY_GAMENAME}" PROPERTIES PREFIX "")
target_link_libraries("lib${LIBSUPERDERPY_GAMENAME}" libsuperderpy ${LIBSUPERDERPY_EXTRA_LIBS})
install(TARGETS "lib${LIBSUPERDERPY_GAMENAME}" DESTINATION ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX})
install(TARGETS "lib${LIBSUPERDERPY_GAMENAME}" DESTINATION ${CMAKE_INSTALL_PREFIX}/${LIB_DIR})
add_subdirectory("gamestates")

View file

@ -37,6 +37,10 @@ if (NOT LIBSUPERDERPY_CONFIG_INCLUDED)
)
add_definitions(-DLIBSUPERDERPY_GIT_REV="${LIBSUPERDERPY_GIT_REV}")
set(SHARE_DIR "share" CACHE STRING "A directory under CMAKE_INSTALL_PREFIX where data files are installed to")
set(BIN_DIR "bin" CACHE STRING "A directory under CMAKE_INSTALL_PREFIX where binary files are installed to")
set(LIB_DIR "lib${LIB_SUFFIX}" CACHE STRING "A directory under CMAKE_INSTALL_PREFIX where library files are installed to")
add_definitions(-D_POSIX_C_SOURCE=200809L)
if (MAEMO5)
add_definitions(-D_GNU_SOURCE)
@ -219,14 +223,14 @@ if (NOT LIBSUPERDERPY_CONFIG_INCLUDED)
add_definitions(-DLIBSUPERDERPY_NO_RESTART=1)
endif(EMSCRIPTEN OR SWITCH)
set(GAMESTATE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
set(GAMESTATE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${LIB_DIR}")
if(APPLE)
if(CMAKE_INSTALL_PREFIX MATCHES "/usr/local") # HACK
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}")
endif(CMAKE_INSTALL_PREFIX MATCHES "/usr/local")
set(GAMESTATE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin/${LIBSUPERDERPY_GAMENAME}.app/Contents/MacOS/")
set(GAMESTATE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${BIN_DIR}/${LIBSUPERDERPY_GAMENAME}.app/Contents/MacOS/")
set(MACOSX_BUNDLE_ICON_FILE ${LIBSUPERDERPY_GAMENAME})
set(MACOSX_BUNDLE_BUNDLE_NAME ${LIBSUPERDERPY_GAMENAME_PRETTY})
@ -250,7 +254,7 @@ if (NOT LIBSUPERDERPY_CONFIG_INCLUDED)
endif(MINGW)
set(CMAKE_INSTALL_RPATH "\$ORIGIN/../lib/${LIBSUPERDERPY_GAMENAME}:\$ORIGIN/gamestates:\$ORIGIN:\$ORIGIN/../lib:\$ORIGIN/lib:\$ORIGIN/bin")
set(CMAKE_INSTALL_RPATH "\$ORIGIN/../${LIB_DIR}/${LIBSUPERDERPY_GAMENAME}:\$ORIGIN/gamestates:\$ORIGIN:\$ORIGIN/../${LIB_DIR}:\$ORIGIN/${LIB_DIR}:\$ORIGIN/${BIN_DIR}")
if(EMSCRIPTEN)
set(CMAKE_EXECUTABLE_SUFFIX ".bc")
@ -405,7 +409,7 @@ if (NOT LIBSUPERDERPY_CONFIG_INCLUDED)
set(ASSET_PIPELINE_DATADIR "${CMAKE_BINARY_DIR}/android/app/src/main/assets/data")
set(ASSET_PIPELINE_DEPEND "")
else (EMSCRIPTEN)
set(ASSET_PIPELINE_DATADIR "${CMAKE_INSTALL_PREFIX}/share/${LIBSUPERDERPY_GAMENAME}/data")
set(ASSET_PIPELINE_DATADIR "${CMAKE_INSTALL_PREFIX}/${SHARE_DIR}/${LIBSUPERDERPY_GAMENAME}/data")
set(ASSET_PIPELINE_DEPEND ${LIBSUPERDERPY_GAMENAME}_install)
endif()
@ -535,7 +539,7 @@ if (NOT LIBSUPERDERPY_CONFIG_INCLUDED)
add_custom_target(${LIBSUPERDERPY_GAMENAME}_js
DEPENDS ${LIBSUPERDERPY_GAMENAME}_install ${LIBSUPERDERPY_GAMENAME}_flac_to_lossy ${LIBSUPERDERPY_GAMENAME}_img_to_webp ${CMAKE_BINARY_DIR}/emscripten-imports.json
WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}/${LIBSUPERDERPY_GAMENAME}"
COMMAND "${CMAKE_C_COMPILER}" ${CFLAGS_LIST} ../bin/${LIBSUPERDERPY_GAMENAME}${CMAKE_EXECUTABLE_SUFFIX} ../lib/libsuperderpy${CMAKE_SHARED_LIBRARY_SUFFIX} ../lib/lib${LIBSUPERDERPY_GAMENAME}${CMAKE_SHARED_LIBRARY_SUFFIX} ${ALLEGRO5_LIBS} ${EMSCRIPTEN_FLAGS} -o ${LIBSUPERDERPY_GAMENAME}.html --pre-js ${LIBSUPERDERPY_DIR}/src/emscripten-pre-js.js --preload-file ../share/${LIBSUPERDERPY_GAMENAME}/data --preload-file gamestates@/
COMMAND "${CMAKE_C_COMPILER}" ${CFLAGS_LIST} ../${BIN_DIR}/${LIBSUPERDERPY_GAMENAME}${CMAKE_EXECUTABLE_SUFFIX} ../lib/libsuperderpy${CMAKE_SHARED_LIBRARY_SUFFIX} ../lib/lib${LIBSUPERDERPY_GAMENAME}${CMAKE_SHARED_LIBRARY_SUFFIX} ${ALLEGRO5_LIBS} ${EMSCRIPTEN_FLAGS} -o ${LIBSUPERDERPY_GAMENAME}.html --pre-js ${LIBSUPERDERPY_DIR}/src/emscripten-pre-js.js --preload-file ../${SHARE_DIR}/${LIBSUPERDERPY_GAMENAME}/data --preload-file gamestates@/
USES_TERMINAL
VERBATIM
)
@ -597,7 +601,7 @@ if (NOT LIBSUPERDERPY_CONFIG_INCLUDED)
# default is to build with RPATH for the install dir, so it doesn't need to relink
if (UNIX)
if (APPLE)
set(CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX})
set(CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/${LIB_DIR})
else (APPLE)
# use the RPATH figured out by cmake when compiling
set(CMAKE_SKIP_BUILD_RPATH TRUE)

View file

@ -72,5 +72,5 @@ if (ANDROID)
endif (ANDROID)
if (NOT LIBSUPERDERPY_STATIC)
install(TARGETS "libsuperderpy" DESTINATION ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX})
install(TARGETS "libsuperderpy" DESTINATION ${CMAKE_INSTALL_PREFIX}/${LIB_DIR})
endif (NOT LIBSUPERDERPY_STATIC)