Improve build configuration options

This commit is contained in:
Perttu Ahola 2012-07-23 15:23:33 +03:00
parent 16fc8b5fc2
commit aef1332e42
7 changed files with 104 additions and 35 deletions

@ -62,7 +62,7 @@ if(WIN32)
elseif(APPLE) elseif(APPLE)
# Random placeholders; this isn't usually used and may not work # Random placeholders; this isn't usually used and may not work
# See https://github.com/toabi/minetest-mac/ # See https://github.com/toabi/minetest-mac/
set(SHAREDIR "share/${PROJECT_NAME}") set(SHAREDIR "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}")
set(BINDIR "bin") set(BINDIR "bin")
set(DOCDIR "share/doc/${PROJECT_NAME}") set(DOCDIR "share/doc/${PROJECT_NAME}")
set(EXAMPLE_CONF_DIR ${DOCDIR}) set(EXAMPLE_CONF_DIR ${DOCDIR})
@ -78,17 +78,58 @@ elseif(UNIX) # Linux, BSD etc
set(ICONDIR "unix/icons") set(ICONDIR "unix/icons")
set(LOCALEDIR "locale") set(LOCALEDIR "locale")
else() else()
set(SHAREDIR "share/${PROJECT_NAME}") set(SHAREDIR "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}")
set(BINDIR "bin") set(BINDIR "${CMAKE_INSTALL_PREFIX}/bin")
set(DOCDIR "share/doc/${PROJECT_NAME}") set(DOCDIR "${CMAKE_INSTALL_PREFIX}/share/doc/${PROJECT_NAME}")
set(MANDIR "share/man") set(MANDIR "${CMAKE_INSTALL_PREFIX}/share/man")
set(EXAMPLE_CONF_DIR ${DOCDIR}) set(EXAMPLE_CONF_DIR ${DOCDIR})
set(XDG_APPS_DIR "share/applications") set(XDG_APPS_DIR "${CMAKE_INSTALL_PREFIX}/share/applications")
set(ICONDIR "share/icons") set(ICONDIR "${CMAKE_INSTALL_PREFIX}/share/icons")
set(LOCALEDIR "share/locale") set(LOCALEDIR "${CMAKE_INSTALL_PREFIX}/share/locale")
endif() endif()
endif() endif()
set(CUSTOM_SHAREDIR "" CACHE STRING "Directory to install data files into")
if(NOT CUSTOM_SHAREDIR STREQUAL "")
set(SHAREDIR "${CUSTOM_SHAREDIR}")
message(STATUS "Using SHAREDIR=${SHAREDIR}")
endif()
set(CUSTOM_BINDIR "" CACHE STRING "Directory to install binaries into")
if(NOT CUSTOM_BINDIR STREQUAL "")
set(BINDIR "${CUSTOM_BINDIR}")
message(STATUS "Using BINDIR=${BINDIR}")
endif()
set(CUSTOM_DOCDIR "" CACHE STRING "Directory to install documentation into")
if(NOT CUSTOM_DOCDIR STREQUAL "")
set(DOCDIR "${CUSTOM_DOCDIR}")
message(STATUS "Using DOCDIR=${DOCDIR}")
endif()
set(CUSTOM_MANDIR "" CACHE STRING "Directory to install manpages into")
if(NOT CUSTOM_MANDIR STREQUAL "")
set(MANDIR "${CUSTOM_MANDIR}")
message(STATUS "Using MANDIR=${MANDIR}")
endif()
set(CUSTOM_EXAMPLE_CONF_DIR "" CACHE STRING "Directory to install example config file into")
if(NOT CUSTOM_EXAMPLE_CONF_DIR STREQUAL "")
set(EXAMPLE_CONF_DIR "${CUSTOM_EXAMPLE_CONF_DIR}")
message(STATUS "Using EXAMPLE_CONF_DIR=${EXAMPLE_CONF_DIR}")
endif()
set(CUSTOM_XDG_APPS_DIR "" CACHE STRING "Directory to install .desktop files into")
if(NOT CUSTOM_XDG_APPS_DIR STREQUAL "")
set(XDG_APPS_DIR "${CUSTOM_XDG_APPS_DIR}")
message(STATUS "Using XDG_APPS_DIR=${XDG_APPS_DIR}")
endif()
set(CUSTOM_ICONDIR "" CACHE STRING "Directory to install icons into")
if(NOT CUSTOM_ICONDIR STREQUAL "")
set(ICONDIR "${CUSTOM_ICONDIR}")
message(STATUS "Using ICONDIR=${ICONDIR}")
endif()
set(CUSTOM_LOCALEDIR "" CACHE STRING "Directory to install l10n files into")
if(NOT CUSTOM_LOCALEDIR STREQUAL "")
set(LOCALEDIR "${CUSTOM_LOCALEDIR}")
message(STATUS "Using LOCALEDIR=${LOCALEDIR}")
endif()
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/builtin" DESTINATION "${SHAREDIR}") install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/builtin" DESTINATION "${SHAREDIR}")
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/games/minimal" DESTINATION "${SHAREDIR}/games") install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/games/minimal" DESTINATION "${SHAREDIR}/games")
set(MINETEST_GAME_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/games/minetest_game") set(MINETEST_GAME_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/games/minetest_game")

@ -1,10 +1,6 @@
project(minetest) project(minetest)
cmake_minimum_required( VERSION 2.6 ) cmake_minimum_required( VERSION 2.6 )
if(RUN_IN_PLACE)
add_definitions ( -DRUN_IN_PLACE )
endif(RUN_IN_PLACE)
# Set some random things default to not being visible in the GUI # Set some random things default to not being visible in the GUI
mark_as_advanced(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH) mark_as_advanced(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH)
mark_as_advanced(JTHREAD_INCLUDE_DIR JTHREAD_LIBRARY) mark_as_advanced(JTHREAD_INCLUDE_DIR JTHREAD_LIBRARY)
@ -139,13 +135,15 @@ else()
#set(CLIENT_PLATFORM_LIBS -lXxf86vm) #set(CLIENT_PLATFORM_LIBS -lXxf86vm)
# This way Xxf86vm is found on OpenBSD too # This way Xxf86vm is found on OpenBSD too
find_library(XXF86VM_LIBRARY Xxf86vm) find_library(XXF86VM_LIBRARY Xxf86vm)
mark_as_advanced(XXF86VM_LIBRARY)
set(CLIENT_PLATFORM_LIBS ${CLIENT_PLATFORM_LIBS} ${XXF86VM_LIBRARY}) set(CLIENT_PLATFORM_LIBS ${CLIENT_PLATFORM_LIBS} ${XXF86VM_LIBRARY})
endif() endif()
find_package(Jthread REQUIRED) find_package(Jthread REQUIRED)
find_package(Sqlite3 REQUIRED) find_package(Sqlite3 REQUIRED)
# TODO: Create proper find script for Lua # Do not use system-wide installation of Lua, because it'll likely be a
# different version and/or has different build options.
set(LUA_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/lua/src") set(LUA_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/lua/src")
set(LUA_LIBRARY "lua") set(LUA_LIBRARY "lua")

@ -4,16 +4,18 @@
#define CMAKE_CONFIG_H #define CMAKE_CONFIG_H
#define CMAKE_PROJECT_NAME "@PROJECT_NAME@" #define CMAKE_PROJECT_NAME "@PROJECT_NAME@"
#define CMAKE_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@"
#define CMAKE_VERSION_STRING "@VERSION_STRING@" #define CMAKE_VERSION_STRING "@VERSION_STRING@"
#define CMAKE_RUN_IN_PLACE @RUN_IN_PLACE@
#define CMAKE_USE_GETTEXT @USE_GETTEXT@
#define CMAKE_USE_SOUND @USE_SOUND@
#define CMAKE_STATIC_SHAREDIR "@SHAREDIR@"
#ifdef NDEBUG #ifdef NDEBUG
#define CMAKE_BUILD_TYPE "Release" #define CMAKE_BUILD_TYPE "Release"
#else #else
#define CMAKE_BUILD_TYPE "Debug" #define CMAKE_BUILD_TYPE "Debug"
#endif #endif
#define CMAKE_USE_GETTEXT @USE_GETTEXT@ #define CMAKE_BUILD_INFO "VER=@VERSION_STRING@ BUILD_TYPE="CMAKE_BUILD_TYPE" RUN_IN_PLACE=@RUN_IN_PLACE@ USE_GETTEXT=@USE_GETTEXT@ USE_SOUND=@USE_SOUND@ STATIC_SHAREDIR=@SHAREDIR@"
#define CMAKE_USE_SOUND @USE_SOUND@
#define CMAKE_BUILD_INFO "VER=@VERSION_STRING@ BUILD_TYPE="CMAKE_BUILD_TYPE" RUN_IN_PLACE=@RUN_IN_PLACE@ USE_GETTEXT=@USE_GETTEXT@ USE_SOUND=@USE_SOUND@ INSTALL_PREFIX=@CMAKE_INSTALL_PREFIX@"
#endif #endif

@ -8,9 +8,10 @@
#define PROJECT_NAME "Minetest" #define PROJECT_NAME "Minetest"
#define VERSION_STRING "unknown" #define VERSION_STRING "unknown"
#define BUILD_TYPE "unknown" #define RUN_IN_PLACE 0
#define USE_GETTEXT 0 #define USE_GETTEXT 0
#define USE_SOUND 0 #define USE_SOUND 0
#define STATIC_SHAREDIR ""
#define BUILD_INFO "non-cmake" #define BUILD_INFO "non-cmake"
#ifdef USE_CMAKE_CONFIG_H #ifdef USE_CMAKE_CONFIG_H
@ -19,12 +20,14 @@
#define PROJECT_NAME CMAKE_PROJECT_NAME #define PROJECT_NAME CMAKE_PROJECT_NAME
#undef VERSION_STRING #undef VERSION_STRING
#define VERSION_STRING CMAKE_VERSION_STRING #define VERSION_STRING CMAKE_VERSION_STRING
#undef BUILD_INFO #undef RUN_IN_PLACE
#define BUILD_INFO CMAKE_BUILD_INFO #define RUN_IN_PLACE CMAKE_RUN_IN_PLACE
#undef USE_GETTEXT #undef USE_GETTEXT
#define USE_GETTEXT CMAKE_USE_GETTEXT #define USE_GETTEXT CMAKE_USE_GETTEXT
#undef USE_SOUND #undef USE_SOUND
#define USE_SOUND CMAKE_USE_SOUND #define USE_SOUND CMAKE_USE_SOUND
#undef STATIC_SHAREDIR
#define STATIC_SHAREDIR CMAKE_STATIC_SHAREDIR
#undef BUILD_INFO #undef BUILD_INFO
#define BUILD_INFO CMAKE_BUILD_INFO #define BUILD_INFO CMAKE_BUILD_INFO
#endif #endif

@ -45,6 +45,7 @@ if(DEFAULT_DLOPEN)
else() else()
option(LUA_USE_DLOPEN "Enable dlopen support." OFF) option(LUA_USE_DLOPEN "Enable dlopen support." OFF)
endif() endif()
mark_as_advanced(LUA_USE_DLOPEN)
if(DEFAULT_POSIX) if(DEFAULT_POSIX)
else() else()
@ -55,6 +56,7 @@ if(DEFAULT_ANSI)
else() else()
option(LUA_ANSI "Disable non-ansi features." OFF) option(LUA_ANSI "Disable non-ansi features." OFF)
endif() endif()
mark_as_advanced(LUA_ANSI)
# #
# Lua version # Lua version

@ -878,7 +878,7 @@ int main(int argc, char *argv[])
// Initialize debug streams // Initialize debug streams
#define DEBUGFILE "debug.txt" #define DEBUGFILE "debug.txt"
#ifdef RUN_IN_PLACE #if RUN_IN_PLACE
std::string logfile = DEBUGFILE; std::string logfile = DEBUGFILE;
#else #else
std::string logfile = porting::path_user+DIR_DELIM+DEBUGFILE; std::string logfile = porting::path_user+DIR_DELIM+DEBUGFILE;
@ -962,7 +962,7 @@ int main(int argc, char *argv[])
// Legacy configuration file location // Legacy configuration file location
filenames.push_back(porting::path_user + filenames.push_back(porting::path_user +
DIR_DELIM + ".." + DIR_DELIM + "minetest.conf"); DIR_DELIM + ".." + DIR_DELIM + "minetest.conf");
#ifdef RUN_IN_PLACE #if RUN_IN_PLACE
// Try also from a lower level (to aid having the same configuration // Try also from a lower level (to aid having the same configuration
// for many RUN_IN_PLACE installs) // for many RUN_IN_PLACE installs)
filenames.push_back(porting::path_user + filenames.push_back(porting::path_user +

@ -29,6 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "filesys.h" #include "filesys.h"
#include "log.h" #include "log.h"
#include "util/string.h" #include "util/string.h"
#include <list>
#ifdef __APPLE__ #ifdef __APPLE__
#include "CoreFoundation/CoreFoundation.h" #include "CoreFoundation/CoreFoundation.h"
@ -154,7 +155,7 @@ bool detectMSVCBuildDir(char *c_path)
void initializePaths() void initializePaths()
{ {
#ifdef RUN_IN_PLACE #if RUN_IN_PLACE
/* /*
Use relative paths if RUN_IN_PLACE Use relative paths if RUN_IN_PLACE
*/ */
@ -252,19 +253,41 @@ void initializePaths()
#elif defined(linux) #elif defined(linux)
#include <unistd.h> #include <unistd.h>
char buf[BUFSIZ];
memset(buf, 0, BUFSIZ);
// Get path to executable // Get path to executable
assert(readlink("/proc/self/exe", buf, BUFSIZ-1) != -1); std::string bindir = "";
{
char buf[BUFSIZ];
memset(buf, 0, BUFSIZ);
assert(readlink("/proc/self/exe", buf, BUFSIZ-1) != -1);
pathRemoveFile(buf, '/');
bindir = buf;
}
pathRemoveFile(buf, '/'); // Find share directory from these.
// It is identified by containing the subdirectory "builtin".
std::list<std::string> trylist;
std::string static_sharedir = STATIC_SHAREDIR;
if(static_sharedir != "" && static_sharedir != ".")
trylist.push_back(static_sharedir);
trylist.push_back(bindir + "/../share/" + PROJECT_NAME);
trylist.push_back(bindir + "/..");
path_share = std::string(buf) + "/../share/" + PROJECT_NAME; for(std::list<std::string>::const_iterator i = trylist.begin();
//path_share = std::string(INSTALL_PREFIX) + "/share/" + PROJECT_NAME; i != trylist.end(); i++)
if (!fs::PathExists(path_share)) { {
dstream<<"WARNING: system-wide share not found at \""<<path_share<<"\""; const std::string &trypath = *i;
path_share = std::string(buf) + "/.."; if(!fs::PathExists(trypath) || !fs::PathExists(trypath + "/builtin")){
dstream<<"WARNING: Using \""<<path_share<<"\" instead."<<std::endl; dstream<<"WARNING: system-wide share not found at \""
<<trypath<<"\""<<std::endl;
continue;
}
// Warn if was not the first alternative
if(i != trylist.begin()){
dstream<<"WARNING: system-wide share found at \""
<<trypath<<"\""<<std::endl;
}
path_share = trypath;
break;
} }
path_user = std::string(getenv("HOME")) + "/." + PROJECT_NAME; path_user = std::string(getenv("HOME")) + "/." + PROJECT_NAME;
@ -297,7 +320,7 @@ void initializePaths()
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__)
path_share = std::string(INSTALL_PREFIX) + "/share/" + PROJECT_NAME; path_share = STATIC_SHAREDIR;
path_user = std::string(getenv("HOME")) + "/." + PROJECT_NAME; path_user = std::string(getenv("HOME")) + "/." + PROJECT_NAME;
#endif #endif