From 4ea8955ad3988caac75d4f762a3cca4da06fd920 Mon Sep 17 00:00:00 2001 From: a_teammate Date: Wed, 14 Dec 2016 02:57:42 +0100 Subject: [PATCH] [REFRACTOR&CMAKE] only one top level "bin"-folder + fix install we had the structure "bin/os/arch", now it all goes to "bin". Every package needs a different bin, so bundling them is stupid anyway. Furthermore this package fixes the install command. --- CMakeLists.txt | 32 +++++++----------------- cmake/functions.cmake | 7 ------ conanfile.txt | 7 ++++++ inexor.bat | 11 +------- inexor/gluegen/require_run_gluegen.cmake | 2 +- inexor/ui/CefSubsystem.cpp | 1 - inexor/ui/InexorSettings.hpp | 9 +++---- inexor_unix | 20 +++------------ server.bat | 11 +------- 9 files changed, 26 insertions(+), 74 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e66db0e27..ab99f12b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,8 @@ conan_basic_setup() # And we split them accordingly into different require_XY() functions include(cmake/require_thirdparty_libs.cmake) -#### Install paths #### + +## Path Variables # Error if paths aren't set well get_filename_component(MAINDIR "${CMAKE_SOURCE_DIR}" REALPATH) # Main inexor folder @@ -47,6 +48,9 @@ endif() # Set the path to inexor/ explicitly to simplify some following definitions set(SOURCE_DIR ${MAINDIR}/inexor) + +## Installation + # INSTALL_LOCALLY will surpress the installation into CMAKE_INSTALL_PREFIX which is by default some global system path. option(INSTALL_LOCALLY "Install everything relative to this folder (${MAINDIR}). Not into some global system directories." ON) @@ -55,30 +59,12 @@ if(INSTALL_LOCALLY) message(STATUS "Local installation chosen. No files will move outside this folder (${MAINDIR}). .. ${CMAKE_INSTALL_PREFIX}") endif() -# Define where to move the binary by target 'install' -if(OS_LINUX) - set(EXE_DIR "bin/linux/${PROJECT_ARCH}") -elseif(OS_MACOSX) - set(EXE_DIR "bin/mac/${PROJECT_ARCH}") -elseif(OS_WINDOWS) - set(EXE_DIR "bin/windows/${PROJECT_ARCH}") -endif() - -set(INSTALL_RESOURCES_DIR "bin/all") +set(EXE_DIR "bin" CACHE STRING "The directory you want to install your executables to. Use target 'install'.") +install(DIRECTORY "${CMAKE_BINARY_DIR}/bin/" DESTINATION "${EXE_DIR}" USE_SOURCE_PERMISSIONS) # Trailing '/' before the DIRECTORY is significant. Without it bin would be installed to bin/bin. message(STATUS "Generating Project-Files to ${CMAKE_CURRENT_BINARY_DIR}") message(STATUS "Resulting Executable goes to ${EXE_DIR}") -### Go for the subfolders. -add_subdirectory(inexor) - -install(FILES ${INSTALL_SHARED_LIBS} ${INSTALL_EXES} DESTINATION ${EXE_DIR}) -install(FILES ${INSTALL_SHARED_LIBS_DEBUG} CONFIGURATIONS Debug DESTINATION ${EXE_DIR}) -install(FILES ${INSTALL_SHARED_LIBS_RELEASE} CONFIGURATIONS Release DESTINATION ${EXE_DIR}) -install(FILES ${INSTALL_RESOURCES} DESTINATION ${INSTALL_RESOURCES_DIR}) -install(DIRECTORY ${INSTALL_RESOURCES_FOLDERS} DESTINATION ${INSTALL_RESOURCES_DIR}) -# shipped portable stuff on win (dirty but temporarily) -if(OS_WINDOWS) - install(DIRECTORY ${INSTALL_PORTABLE_DIR} DESTINATION "bin/windows/all") -endif() +## Go for the source subfolder. +add_subdirectory(inexor) diff --git a/cmake/functions.cmake b/cmake/functions.cmake index 9104759ab..e906c2a2b 100644 --- a/cmake/functions.cmake +++ b/cmake/functions.cmake @@ -237,14 +237,7 @@ function(add_app exe) set_property(TARGET ${exe} PROPERTY FOLDER "executables") endif() - # on visual studio we want to copy the seperate debug-info file - if(MSVC) - set(pdbfile "${CMAKE_CURRENT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}/${exe}.pdb") - install(FILES ${pdbfile} DESTINATION ${EXE_DIR} OPTIONAL) - endif() - target_link_libraries(${exe} ${CONAN_LIBS}) - install(TARGETS ${exe} DESTINATION ${EXE_DIR}) endfunction() # USAGE: add_lib(modulename) diff --git a/conanfile.txt b/conanfile.txt index 8738836d2..5c09c6a3a 100644 --- a/conanfile.txt +++ b/conanfile.txt @@ -24,3 +24,10 @@ SDL2:shared=False SDL2_image:shared=False CEF:use_sandbox=False + +[imports] + bin, *.dll -> ./bin + bin, *.bin -> ./bin + bin, *.dat -> ./bin + bin, *.pak -> ./bin + lib, *.dylib* -> ./bin diff --git a/inexor.bat b/inexor.bat index 838defa5b..6f80a2a4f 100644 --- a/inexor.bat +++ b/inexor.bat @@ -1,19 +1,10 @@ @ECHO OFF Setlocal EnableDelayedExpansion -set INEXOR_ARCH=32 - -IF /I "%PROCESSOR_ARCHITECTURE%" == "amd64" ( - set INEXOR_ARCH=64 -) -IF /I "%PROCESSOR_ARCHITEW6432%" == "amd64" ( - set INEXOR_ARCH=64 -) - :: Clear variable set "DATA_DIRS=" :: Find all data repos in media for /f "delims=" %%a in ('dir "./media" /on /ad /b') do @set "DATA_DIRS=!DATA_DIRS! -kmedia/%%a/" -start bin\windows\%INEXOR_ARCH%\inexor.exe "-q$HOME\My Games\Inexor" %DATA_DIRS% -glog.txt %* +start bin\inexor.exe "-q$HOME\My Games\Inexor" %DATA_DIRS% -glog.txt %* start /B inexor_node_windows.bat diff --git a/inexor/gluegen/require_run_gluegen.cmake b/inexor/gluegen/require_run_gluegen.cmake index 80cd2d810..1b76ef040 100644 --- a/inexor/gluegen/require_run_gluegen.cmake +++ b/inexor/gluegen/require_run_gluegen.cmake @@ -109,7 +109,7 @@ function(require_run_gluegen TARG BUILDFLAGS TEMPLATES_DIR OUT_DIR) ) message(STATUS "gluegen will generate the following files: ${GENERATED_FILES}") - install(FILES ${gluegen_out_proto} DESTINATION ${INSTALL_RESOURCES_DIR} RENAME ${proto_general_name}) # install .proto to bin/all + install(FILES ${gluegen_out_proto} DESTINATION ${EXE_DIR} RENAME ${proto_general_name}) # install .proto to bin/all message(STATUS "Proto file install destination: ${INSTALL_RESOURCES_DIR}/${proto_general_name}") endfunction() diff --git a/inexor/ui/CefSubsystem.cpp b/inexor/ui/CefSubsystem.cpp index a7e986a15..f51b4a5aa 100644 --- a/inexor/ui/CefSubsystem.cpp +++ b/inexor/ui/CefSubsystem.cpp @@ -50,7 +50,6 @@ void CefSubsystem::initialize(int argc, char **argv) const CefMainArgs args(argc, argv); #endif std::string executable_path = ExecutablePathWithoutBinary(argv[0]); - spdlog::get("global")->info("Detected executable path: {}", executable_path); InexorSettings settings(executable_path); if (!CefInitialize(args, settings, cef_app.get(), NULL)) { spdlog::get("global")->error("FATAL: Initialization of CEF subprocess failed!"); diff --git a/inexor/ui/InexorSettings.hpp b/inexor/ui/InexorSettings.hpp index ee1c9dc6b..43aecfbf3 100644 --- a/inexor/ui/InexorSettings.hpp +++ b/inexor/ui/InexorSettings.hpp @@ -39,12 +39,11 @@ class InexorSettings : public CefSettings char base_path[FILENAME_MAX]; GetCurrentDir(base_path, sizeof(base_path)); - CefString(&resources_dir_path).FromString(std::string(base_path) + "/bin/all"); - CefString(&locales_dir_path).FromString(std::string(base_path) + "/bin/all/locales"); - CefString(&log_file).FromString(std::string(base_path) + "/inexorcef.log"); + CefString(&resources_dir_path).FromString(executable_path); + CefString(&locales_dir_path).FromString(executable_path + "/locales"); + CefString(&log_file).FromString(std::string(base_path) + "inexorcef.log"); // TODO: make adaptable. spdlog::get("global")->info("init: cef: setting subprocess executable_path: {}", executable_path); - spdlog::get("global")->info("init: cef: base path: {}", base_path); - CefString(&browser_subprocess_path).FromString(std::string(executable_path) + "/cef_subprocess"); + CefString(&browser_subprocess_path).FromString(executable_path + "/cef_subprocess"); } }; diff --git a/inexor_unix b/inexor_unix index 74f466234..5fca00065 100755 --- a/inexor_unix +++ b/inexor_unix @@ -1,24 +1,10 @@ #!/bin/bash -tolower() { - tr '[:upper:]' '[:lower:]' -} - -arch="`uname -m | tolower`" -# Rename the arch to bare style -if [ "${arch}" = "x86_64" ] -then - arch="64" -else - arch="32" -fi dir="`dirname "$0"`" -os="`uname | tolower`" -bin="${dir}/bin/${os}/${arch}" -exe="${bin}/inexor" +exe="${dir}/bin/inexor" -ln -sf /lib/${arch}-linux-gnu/libudev.so.1 ${bin}/libudev.so.0 -export LD_LIBRARY_PATH="$bin:$LD_LIBRARY_PATH" +# Maybe we need to set them to the conan lib dirs: +export LD_LIBRARY_PATH="${dir}/bin:$LD_LIBRARY_PATH" source inexor_node_unix& echo >&2 "CALLING: ${exe}" diff --git a/server.bat b/server.bat index 5f2bf39c4..044863a13 100644 --- a/server.bat +++ b/server.bat @@ -1,12 +1,3 @@ @ECHO OFF -set INEXOR_ARCH=win32 - -IF /I "%PROCESSOR_ARCHITECTURE%" == "amd64" ( - set INEXOR_ARCH=win64 -) -IF /I "%PROCESSOR_ARCHITEW6432%" == "amd64" ( - set INEXOR_ARCH=win64 -) - -start bin\windows\%INEXOR_ARCH%\inexor.exe "-q$HOME\My Games\Inexor" -gserver-log.txt -d %* +start bin\server.exe "-q$HOME\My Games\Inexor" -gserver-log.txt -d %*