New CMAKE bundle option
on behalf of L.Jirkovsky, see issue 184
This commit is contained in:
@@ -62,61 +62,74 @@ option (WITH_RAWZOR "Build with Rawzor support" OFF)
|
||||
option (WITH_BZIP "Build with Bzip2 support" ON)
|
||||
option (WITH_MYFILE_MMAP "Build using memory mapped file" ON)
|
||||
option (OPTION_OMP "Build with OpenMP support" ON)
|
||||
option (BUILD_BUNDLE "Self-contained build" OFF)
|
||||
|
||||
# set install directories
|
||||
if (NOT DEFINED DATADIR)
|
||||
if (WIN32 OR APPLE)
|
||||
set (DATADIR ${CMAKE_CURRENT_SOURCE_DIR}/release)
|
||||
else (WIN32 OR APPLE)
|
||||
set (DATADIR ${CMAKE_INSTALL_PREFIX}/share/rawtherapee)
|
||||
endif (WIN32 OR APPLE)
|
||||
endif (NOT DEFINED DATADIR)
|
||||
if (WIN32 OR APPLE)
|
||||
set (BUILD_BUNDLE ON FORCE)
|
||||
endif(WIN32 OR APPLE)
|
||||
|
||||
if (BUILD_BUNDLE)
|
||||
set (BINDIR .)
|
||||
set (CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_BUILD_TYPE})
|
||||
endif (BUILD_BUNDLE)
|
||||
|
||||
if (NOT DEFINED BINDIR)
|
||||
if (WIN32 OR APPLE)
|
||||
set (BINDIR ${CMAKE_CURRENT_SOURCE_DIR}/release)
|
||||
else (WIN32 OR APPLE)
|
||||
set (BINDIR ${CMAKE_INSTALL_PREFIX}/bin)
|
||||
endif (WIN32 OR APPLE)
|
||||
endif (NOT DEFINED BINDIR)
|
||||
|
||||
if (NOT DEFINED DATADIR)
|
||||
if (BUILD_BUNDLE)
|
||||
set (DATADIR .)
|
||||
else (BUILD_BUNDLE)
|
||||
set (DATADIR ${CMAKE_INSTALL_PREFIX}/share/rawtherapee)
|
||||
endif (BUILD_BUNDLE)
|
||||
endif (NOT DEFINED DATADIR)
|
||||
|
||||
if (NOT DEFINED LIBDIR)
|
||||
if (WIN32 OR APPLE)
|
||||
set (LIBDIR ${CMAKE_CURRENT_SOURCE_DIR}/release)
|
||||
else (WIN32 OR APPLE)
|
||||
if (BUILD_BUNDLE)
|
||||
set (LIBDIR .)
|
||||
else (BUILD_BUNDLE)
|
||||
# Respect CMAKE_INSTALL_LIBDIR if set
|
||||
if (DEFINED CMAKE_INSTALL_LIBDIR)
|
||||
set (LIBDIR ${CMAKE_INSTALL_LIBDIR})
|
||||
else (DEFINED CMAKE_INSTALL_LIBDIR)
|
||||
set (LIBDIR ${CMAKE_INSTALL_PREFIX}/lib)
|
||||
endif (DEFINED CMAKE_INSTALL_LIBDIR)
|
||||
endif (WIN32 OR APPLE)
|
||||
endif (BUILD_BUNDLE)
|
||||
endif (NOT DEFINED LIBDIR)
|
||||
|
||||
if (NOT DEFINED DOCDIR)
|
||||
if (WIN32 OR APPLE)
|
||||
set (DOCDIR ${CMAKE_CURRENT_SOURCE_DIR}/release/doc)
|
||||
else (WIN32 OR APPLE)
|
||||
set (DOCDIR ${CMAKE_INSTALL_PREFIX}/share/doc)
|
||||
endif (WIN32 OR APPLE)
|
||||
if (BUILD_BUNDLE)
|
||||
set (DOCDIR ./doc)
|
||||
else (BUILD_BUNDLE)
|
||||
set (DOCDIR ${CMAKE_INSTALL_PREFIX}/share/doc/rawtherapee)
|
||||
endif (BUILD_BUNDLE)
|
||||
endif (NOT DEFINED DOCDIR)
|
||||
|
||||
if (NOT DEFINED CREDITSDIR)
|
||||
if (WIN32 OR APPLE)
|
||||
set (CREDITSDIR ${CMAKE_CURRENT_SOURCE_DIR}/release)
|
||||
else (WIN32 OR APPLE)
|
||||
set (CREDITSDIR ${CMAKE_INSTALL_PREFIX}/share/doc)
|
||||
endif (WIN32 OR APPLE)
|
||||
if (BUILD_BUNDLE)
|
||||
set (CREDITSDIR .)
|
||||
else (BUILD_BUNDLE)
|
||||
set (CREDITSDIR ${CMAKE_INSTALL_PREFIX}/share/doc/rawtherapee)
|
||||
endif (BUILD_BUNDLE)
|
||||
endif (NOT DEFINED CREDITSDIR)
|
||||
|
||||
if (NOT DEFINED LICENCEDIR)
|
||||
if (WIN32 OR APPLE)
|
||||
set (LICENCEDIR ${CMAKE_CURRENT_SOURCE_DIR}/release)
|
||||
else (WIN32 OR APPLE)
|
||||
set (LICENCEDIR ${CMAKE_INSTALL_PREFIX}/share/doc)
|
||||
endif (WIN32 OR APPLE)
|
||||
if (BUILD_BUNDLE)
|
||||
set (LICENCEDIR .)
|
||||
else (BUILD_BUNDLE)
|
||||
set (LICENCEDIR ${CMAKE_INSTALL_PREFIX}/share/doc/rawtherapee)
|
||||
endif (BUILD_BUNDLE)
|
||||
endif (NOT DEFINED LICENCEDIR)
|
||||
|
||||
# non-bundle builds has to use absolute paths
|
||||
if (NOT BUILD_BUNDLE AND
|
||||
NOT (IS_ABSOLUTE ${BINDIR} AND IS_ABSOLUTE ${DATADIR} AND IS_ABSOLUTE ${LIBDIR} AND
|
||||
IS_ABSOLUTE ${DOCDIR} AND IS_ABSOLUTE ${CREDITSDIR} AND IS_ABSOLUTE ${LICENCEDIR}))
|
||||
message (FATAL_ERROR "The paths has to be absolute or use -DBUILD_BUNDLE=ON")
|
||||
endif ()
|
||||
|
||||
# check for libraries
|
||||
find_package(PkgConfig)
|
||||
pkg_check_modules (GTK REQUIRED gtk+-2.0>=2.12)
|
||||
@@ -314,10 +327,6 @@ if (OPTION_OMP)
|
||||
endif (OPENMP_FOUND)
|
||||
endif (OPTION_OMP)
|
||||
|
||||
if (UNIX)
|
||||
install (PROGRAMS rtstart DESTINATION ${BINDIR})
|
||||
endif (UNIX)
|
||||
|
||||
install (FILES AUTHORS.txt DESTINATION ${CREDITSDIR})
|
||||
install (FILES LICENSE.txt DESTINATION ${LICENCEDIR})
|
||||
install (FILES AboutThisBuild.txt DESTINATION ${CREDITSDIR})
|
||||
|
@@ -44,9 +44,9 @@ else (WIN32)
|
||||
${GTK_INCLUDE_DIRS} ${GTKMM_INCLUDE_DIRS} ${GIO_INCLUDE_DIRS} ${GIOMM_INCLUDE_DIRS} ${IPTCDATA_INCLUDE_DIRS} ${LCMS_INCLUDE_DIRS} ${GTHREAD_INCLUDE_DIRS} ${GOBJECT_INCLUDE_DIRS} )
|
||||
link_directories (${EXTRA_LIBDIR} ${GLIB2_LIBRARY_DIRS} ${GLIBMM_LIBRARY_DIRS}
|
||||
${GTK_LIBRARY_DIRS} ${GTKMM_LIBRARY_DIRS} ${GIO_LIBRARY_DIRS} ${GIOMM_LIBRARY_DIRS} ${IPTCDATA_LIBRARY_DIRS} ${LCMS_LIBRARY_DIRS} ${GTHREAD_LIBRARY_DIRS} ${GOBJECT_LIBRARY_DIRS})
|
||||
# create config.h which defines where data are stored
|
||||
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
||||
endif (WIN32)
|
||||
# create config.h which defines where data are stored
|
||||
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
||||
|
||||
add_executable (rth ${EXTRA_SRC} ${BASESOURCEFILES})
|
||||
|
||||
|
@@ -20,6 +20,7 @@
|
||||
#ifndef __CONFIG_H__
|
||||
#define __CONFIG_H__
|
||||
|
||||
#cmakedefine BUILD_BUNDLE
|
||||
#define DATA_SEARCH_PATH "${DATADIR}"
|
||||
#define DOC_SEARCH_PATH "${DOCDIR}"
|
||||
#define CREDITS_SEARCH_PATH "${CREDITSDIR}"
|
||||
|
@@ -23,7 +23,7 @@
|
||||
|
||||
// This file is for your program, I won't touch it again!
|
||||
|
||||
//#include <config.h>
|
||||
#include <config.h>
|
||||
#include <gtkmm.h>
|
||||
#include <giomm.h>
|
||||
#include <iostream>
|
||||
@@ -35,7 +35,6 @@
|
||||
#include "version.h"
|
||||
|
||||
#ifndef WIN32
|
||||
#include <config.h>
|
||||
#include <glibmm/fileutils.h>
|
||||
#include <glib.h>
|
||||
#include <glib/gstdio.h>
|
||||
@@ -47,6 +46,8 @@ extern Options options;
|
||||
|
||||
// stores path to data files
|
||||
Glib::ustring argv0;
|
||||
Glib::ustring creditsPath;
|
||||
Glib::ustring licensePath;
|
||||
Glib::ustring argv1;
|
||||
bool simpleEditor;
|
||||
|
||||
@@ -61,34 +62,43 @@ int processLineParams( int argc, char **argv );
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
Glib::ustring argv0_;
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
WCHAR exnameU[512] = {0};
|
||||
#ifdef BUILD_BUNDLE
|
||||
char exname[512] = {0};
|
||||
Glib::ustring exePath;
|
||||
// get the path where the rawtherapee executable is stored
|
||||
#ifdef WIN32
|
||||
WCHAR exnameU[512] = {0};
|
||||
GetModuleFileNameW (NULL, exnameU, 512);
|
||||
WideCharToMultiByte(CP_UTF8,0,exnameU,-1,exname,512,0,0 );
|
||||
argv0_ = exname;
|
||||
|
||||
// get the path where the rawtherapee executable is stored
|
||||
argv0 = Glib::path_get_dirname(argv0_);
|
||||
|
||||
#else
|
||||
// get the path to data (defined in config.h which is generated by cmake)
|
||||
argv0 = DATA_SEARCH_PATH;
|
||||
// check if path exists, otherwise revert back to behavior similar to windows
|
||||
try {
|
||||
Glib::Dir dir(DATA_SEARCH_PATH);
|
||||
} catch (Glib::FileError) {
|
||||
argv0_ = argv[0];
|
||||
argv0 = Glib::path_get_dirname(argv0_);
|
||||
#else
|
||||
if (readlink("/proc/self/exe", exname, 512) < 0) {
|
||||
strncpy(exname, argv[0], 512);
|
||||
}
|
||||
#endif
|
||||
exePath = Glib::path_get_dirname(exname);
|
||||
|
||||
// set paths
|
||||
if (Glib::path_is_absolute(DATA_SEARCH_PATH)) {
|
||||
argv0 = DATA_SEARCH_PATH;
|
||||
} else {
|
||||
argv0 = Glib::build_filename(exePath, DATA_SEARCH_PATH);
|
||||
}
|
||||
if (Glib::path_is_absolute(CREDITS_SEARCH_PATH)) {
|
||||
creditsPath = CREDITS_SEARCH_PATH;
|
||||
} else {
|
||||
creditsPath = Glib::build_filename(exePath, CREDITS_SEARCH_PATH);
|
||||
}
|
||||
if (Glib::path_is_absolute(LICENCE_SEARCH_PATH)) {
|
||||
licensePath = LICENCE_SEARCH_PATH;
|
||||
} else {
|
||||
licensePath = Glib::build_filename(exePath, LICENCE_SEARCH_PATH);
|
||||
}
|
||||
#else
|
||||
argv0 = DATA_SEARCH_PATH;
|
||||
creditsPath = CREDITS_SEARCH_PATH;
|
||||
licensePath = LICENCE_SEARCH_PATH;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
Glib::thread_init();
|
||||
gdk_threads_init();
|
||||
Gio::init ();
|
||||
@@ -146,7 +156,6 @@ int main(int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int processLineParams( int argc, char **argv )
|
||||
{
|
||||
std::vector<Glib::ustring> inputFiles;
|
||||
|
@@ -21,11 +21,9 @@
|
||||
#include <glib/gstdio.h>
|
||||
#include <safegtk.h>
|
||||
|
||||
#ifndef WIN32
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
extern Glib::ustring argv0;
|
||||
extern Glib::ustring creditsPath;
|
||||
extern Glib::ustring licensePath;
|
||||
extern Glib::ustring versionString;
|
||||
|
||||
SplashImage::SplashImage () {
|
||||
@@ -86,11 +84,7 @@ Splash::Splash () {
|
||||
splashImage->show ();
|
||||
|
||||
// Tab 2: the informations about the current version
|
||||
#if defined WIN32 || defined __APPLE__
|
||||
std::string buildFileName = Glib::build_filename (argv0, "AboutThisBuild.txt");
|
||||
#else
|
||||
std::string buildFileName = Glib::build_filename (CREDITS_SEARCH_PATH, "AboutThisBuild.txt");
|
||||
#endif
|
||||
std::string buildFileName = Glib::build_filename (creditsPath, "AboutThisBuild.txt");
|
||||
if ( safe_file_test(buildFileName, (Glib::FILE_TEST_EXISTS)) ) {
|
||||
FILE *f = safe_g_fopen (buildFileName, "rt");
|
||||
if (f != NULL) {
|
||||
@@ -113,11 +107,7 @@ Splash::Splash () {
|
||||
}
|
||||
|
||||
// Tab 3: the credits
|
||||
#if defined WIN32 || defined __APPLE__
|
||||
std::string creditsFileName = Glib::build_filename (argv0, "AUTHORS.txt");
|
||||
#else
|
||||
std::string creditsFileName = Glib::build_filename (CREDITS_SEARCH_PATH, "AUTHORS.txt");
|
||||
#endif
|
||||
std::string creditsFileName = Glib::build_filename (creditsPath, "AUTHORS.txt");
|
||||
if ( safe_file_test(creditsFileName, (Glib::FILE_TEST_EXISTS)) ) {
|
||||
FILE *f = safe_g_fopen (creditsFileName, "rt");
|
||||
if (f != NULL) {
|
||||
@@ -140,11 +130,7 @@ Splash::Splash () {
|
||||
}
|
||||
|
||||
// Tab 4: the license
|
||||
#if defined WIN32 || defined __APPLE__
|
||||
std::string licenseFileName = Glib::build_filename (argv0, "LICENSE.txt");
|
||||
#else
|
||||
std::string licenseFileName = Glib::build_filename (LICENCE_SEARCH_PATH, "LICENSE.txt");
|
||||
#endif
|
||||
std::string licenseFileName = Glib::build_filename (licensePath, "LICENSE.txt");
|
||||
if ( safe_file_test(licenseFileName, (Glib::FILE_TEST_EXISTS)) ) {
|
||||
FILE *f = safe_g_fopen (licenseFileName, "rt");
|
||||
if (f != NULL) {
|
||||
|
Reference in New Issue
Block a user