New CMAKE bundle option

on behalf of L.Jirkovsky, see issue 184
This commit is contained in:
Oliver Duis
2011-07-08 17:53:29 +02:00
parent 76c0aae328
commit e0a273904a
6 changed files with 99 additions and 98 deletions

View File

@@ -62,61 +62,74 @@ option (WITH_RAWZOR "Build with Rawzor support" OFF)
option (WITH_BZIP "Build with Bzip2 support" ON) option (WITH_BZIP "Build with Bzip2 support" ON)
option (WITH_MYFILE_MMAP "Build using memory mapped file" ON) option (WITH_MYFILE_MMAP "Build using memory mapped file" ON)
option (OPTION_OMP "Build with OpenMP support" ON) option (OPTION_OMP "Build with OpenMP support" ON)
option (BUILD_BUNDLE "Self-contained build" OFF)
# set install directories # set install directories
if (NOT DEFINED DATADIR) if (WIN32 OR APPLE)
if (WIN32 OR APPLE) set (BUILD_BUNDLE ON FORCE)
set (DATADIR ${CMAKE_CURRENT_SOURCE_DIR}/release) endif(WIN32 OR APPLE)
else (WIN32 OR APPLE)
set (DATADIR ${CMAKE_INSTALL_PREFIX}/share/rawtherapee) if (BUILD_BUNDLE)
endif (WIN32 OR APPLE) set (BINDIR .)
endif (NOT DEFINED DATADIR) set (CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_BUILD_TYPE})
endif (BUILD_BUNDLE)
if (NOT DEFINED BINDIR) if (NOT DEFINED BINDIR)
if (WIN32 OR APPLE) set (BINDIR ${CMAKE_INSTALL_PREFIX}/bin)
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) 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 (NOT DEFINED LIBDIR)
if (WIN32 OR APPLE) if (BUILD_BUNDLE)
set (LIBDIR ${CMAKE_CURRENT_SOURCE_DIR}/release) set (LIBDIR .)
else (WIN32 OR APPLE) else (BUILD_BUNDLE)
# Respect CMAKE_INSTALL_LIBDIR if set # Respect CMAKE_INSTALL_LIBDIR if set
if (DEFINED CMAKE_INSTALL_LIBDIR) if (DEFINED CMAKE_INSTALL_LIBDIR)
set (LIBDIR ${CMAKE_INSTALL_LIBDIR}) set (LIBDIR ${CMAKE_INSTALL_LIBDIR})
else (DEFINED CMAKE_INSTALL_LIBDIR) else (DEFINED CMAKE_INSTALL_LIBDIR)
set (LIBDIR ${CMAKE_INSTALL_PREFIX}/lib) set (LIBDIR ${CMAKE_INSTALL_PREFIX}/lib)
endif (DEFINED CMAKE_INSTALL_LIBDIR) endif (DEFINED CMAKE_INSTALL_LIBDIR)
endif (WIN32 OR APPLE) endif (BUILD_BUNDLE)
endif (NOT DEFINED LIBDIR) endif (NOT DEFINED LIBDIR)
if (NOT DEFINED DOCDIR) if (NOT DEFINED DOCDIR)
if (WIN32 OR APPLE) if (BUILD_BUNDLE)
set (DOCDIR ${CMAKE_CURRENT_SOURCE_DIR}/release/doc) set (DOCDIR ./doc)
else (WIN32 OR APPLE) else (BUILD_BUNDLE)
set (DOCDIR ${CMAKE_INSTALL_PREFIX}/share/doc) set (DOCDIR ${CMAKE_INSTALL_PREFIX}/share/doc/rawtherapee)
endif (WIN32 OR APPLE) endif (BUILD_BUNDLE)
endif (NOT DEFINED DOCDIR) endif (NOT DEFINED DOCDIR)
if (NOT DEFINED CREDITSDIR) if (NOT DEFINED CREDITSDIR)
if (WIN32 OR APPLE) if (BUILD_BUNDLE)
set (CREDITSDIR ${CMAKE_CURRENT_SOURCE_DIR}/release) set (CREDITSDIR .)
else (WIN32 OR APPLE) else (BUILD_BUNDLE)
set (CREDITSDIR ${CMAKE_INSTALL_PREFIX}/share/doc) set (CREDITSDIR ${CMAKE_INSTALL_PREFIX}/share/doc/rawtherapee)
endif (WIN32 OR APPLE) endif (BUILD_BUNDLE)
endif (NOT DEFINED CREDITSDIR) endif (NOT DEFINED CREDITSDIR)
if (NOT DEFINED LICENCEDIR) if (NOT DEFINED LICENCEDIR)
if (WIN32 OR APPLE) if (BUILD_BUNDLE)
set (LICENCEDIR ${CMAKE_CURRENT_SOURCE_DIR}/release) set (LICENCEDIR .)
else (WIN32 OR APPLE) else (BUILD_BUNDLE)
set (LICENCEDIR ${CMAKE_INSTALL_PREFIX}/share/doc) set (LICENCEDIR ${CMAKE_INSTALL_PREFIX}/share/doc/rawtherapee)
endif (WIN32 OR APPLE) endif (BUILD_BUNDLE)
endif (NOT DEFINED LICENCEDIR) 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 # check for libraries
find_package(PkgConfig) find_package(PkgConfig)
pkg_check_modules (GTK REQUIRED gtk+-2.0>=2.12) pkg_check_modules (GTK REQUIRED gtk+-2.0>=2.12)
@@ -314,10 +327,6 @@ if (OPTION_OMP)
endif (OPENMP_FOUND) endif (OPENMP_FOUND)
endif (OPTION_OMP) endif (OPTION_OMP)
if (UNIX)
install (PROGRAMS rtstart DESTINATION ${BINDIR})
endif (UNIX)
install (FILES AUTHORS.txt DESTINATION ${CREDITSDIR}) install (FILES AUTHORS.txt DESTINATION ${CREDITSDIR})
install (FILES LICENSE.txt DESTINATION ${LICENCEDIR}) install (FILES LICENSE.txt DESTINATION ${LICENCEDIR})
install (FILES AboutThisBuild.txt DESTINATION ${CREDITSDIR}) install (FILES AboutThisBuild.txt DESTINATION ${CREDITSDIR})

View File

@@ -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} ) ${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} 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}) ${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) 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}) add_executable (rth ${EXTRA_SRC} ${BASESOURCEFILES})

View File

@@ -20,6 +20,7 @@
#ifndef __CONFIG_H__ #ifndef __CONFIG_H__
#define __CONFIG_H__ #define __CONFIG_H__
#cmakedefine BUILD_BUNDLE
#define DATA_SEARCH_PATH "${DATADIR}" #define DATA_SEARCH_PATH "${DATADIR}"
#define DOC_SEARCH_PATH "${DOCDIR}" #define DOC_SEARCH_PATH "${DOCDIR}"
#define CREDITS_SEARCH_PATH "${CREDITSDIR}" #define CREDITS_SEARCH_PATH "${CREDITSDIR}"

View File

@@ -23,7 +23,7 @@
// This file is for your program, I won't touch it again! // This file is for your program, I won't touch it again!
//#include <config.h> #include <config.h>
#include <gtkmm.h> #include <gtkmm.h>
#include <giomm.h> #include <giomm.h>
#include <iostream> #include <iostream>
@@ -35,7 +35,6 @@
#include "version.h" #include "version.h"
#ifndef WIN32 #ifndef WIN32
#include <config.h>
#include <glibmm/fileutils.h> #include <glibmm/fileutils.h>
#include <glib.h> #include <glib.h>
#include <glib/gstdio.h> #include <glib/gstdio.h>
@@ -47,6 +46,8 @@ extern Options options;
// stores path to data files // stores path to data files
Glib::ustring argv0; Glib::ustring argv0;
Glib::ustring creditsPath;
Glib::ustring licensePath;
Glib::ustring argv1; Glib::ustring argv1;
bool simpleEditor; bool simpleEditor;
@@ -60,34 +61,43 @@ bool simpleEditor;
int processLineParams( int argc, char **argv ); int processLineParams( int argc, char **argv );
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
#ifdef BUILD_BUNDLE
Glib::ustring argv0_; char exname[512] = {0};
Glib::ustring exePath;
#ifdef WIN32 // get the path where the rawtherapee executable is stored
#ifdef WIN32
WCHAR exnameU[512] = {0}; WCHAR exnameU[512] = {0};
char exname[512] = {0}; GetModuleFileNameW (NULL, exnameU, 512);
GetModuleFileNameW (NULL, exnameU, 512); WideCharToMultiByte(CP_UTF8,0,exnameU,-1,exname,512,0,0 );
WideCharToMultiByte(CP_UTF8,0,exnameU,-1,exname,512,0,0 ); #else
argv0_ = exname; if (readlink("/proc/self/exe", exname, 512) < 0) {
strncpy(exname, argv[0], 512);
// get the path where the rawtherapee executable is stored }
argv0 = Glib::path_get_dirname(argv0_); #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 #else
// get the path to data (defined in config.h which is generated by cmake) argv0 = DATA_SEARCH_PATH;
argv0 = DATA_SEARCH_PATH; creditsPath = CREDITS_SEARCH_PATH;
// check if path exists, otherwise revert back to behavior similar to windows licensePath = LICENCE_SEARCH_PATH;
try {
Glib::Dir dir(DATA_SEARCH_PATH);
} catch (Glib::FileError) {
argv0_ = argv[0];
argv0 = Glib::path_get_dirname(argv0_);
}
#endif #endif
Glib::thread_init(); Glib::thread_init();
gdk_threads_init(); gdk_threads_init();
@@ -127,16 +137,16 @@ int main(int argc, char **argv)
} }
Gtk::Main m(&argc, &argv); Gtk::Main m(&argc, &argv);
#ifndef WIN32 #ifndef WIN32
// For an unknown reason, gtkmm 2.22 don't know the gtk-button-images property, while it exists in the documentation... // For an unknown reason, gtkmm 2.22 don't know the gtk-button-images property, while it exists in the documentation...
// Anyway, the problem was Linux only // Anyway, the problem was Linux only
static Glib::RefPtr<Gtk::Settings> settings = Gtk::Settings::get_default(); static Glib::RefPtr<Gtk::Settings> settings = Gtk::Settings::get_default();
if (settings) if (settings)
settings->property_gtk_button_images().set_value(true); settings->property_gtk_button_images().set_value(true);
else else
printf("Error: no default settings to update!\n"); printf("Error: no default settings to update!\n");
#endif #endif
RTWindow *rtWindow = new class RTWindow(); RTWindow *rtWindow = new class RTWindow();
gdk_threads_enter (); gdk_threads_enter ();
m.run(*rtWindow); m.run(*rtWindow);
@@ -146,7 +156,6 @@ int main(int argc, char **argv)
return 0; return 0;
} }
int processLineParams( int argc, char **argv ) int processLineParams( int argc, char **argv )
{ {
std::vector<Glib::ustring> inputFiles; std::vector<Glib::ustring> inputFiles;

View File

@@ -21,11 +21,9 @@
#include <glib/gstdio.h> #include <glib/gstdio.h>
#include <safegtk.h> #include <safegtk.h>
#ifndef WIN32
#include <config.h>
#endif
extern Glib::ustring argv0; extern Glib::ustring argv0;
extern Glib::ustring creditsPath;
extern Glib::ustring licensePath;
extern Glib::ustring versionString; extern Glib::ustring versionString;
SplashImage::SplashImage () { SplashImage::SplashImage () {
@@ -86,11 +84,7 @@ Splash::Splash () {
splashImage->show (); splashImage->show ();
// Tab 2: the informations about the current version // Tab 2: the informations about the current version
#if defined WIN32 || defined __APPLE__ std::string buildFileName = Glib::build_filename (creditsPath, "AboutThisBuild.txt");
std::string buildFileName = Glib::build_filename (argv0, "AboutThisBuild.txt");
#else
std::string buildFileName = Glib::build_filename (CREDITS_SEARCH_PATH, "AboutThisBuild.txt");
#endif
if ( safe_file_test(buildFileName, (Glib::FILE_TEST_EXISTS)) ) { if ( safe_file_test(buildFileName, (Glib::FILE_TEST_EXISTS)) ) {
FILE *f = safe_g_fopen (buildFileName, "rt"); FILE *f = safe_g_fopen (buildFileName, "rt");
if (f != NULL) { if (f != NULL) {
@@ -113,11 +107,7 @@ Splash::Splash () {
} }
// Tab 3: the credits // Tab 3: the credits
#if defined WIN32 || defined __APPLE__ std::string creditsFileName = Glib::build_filename (creditsPath, "AUTHORS.txt");
std::string creditsFileName = Glib::build_filename (argv0, "AUTHORS.txt");
#else
std::string creditsFileName = Glib::build_filename (CREDITS_SEARCH_PATH, "AUTHORS.txt");
#endif
if ( safe_file_test(creditsFileName, (Glib::FILE_TEST_EXISTS)) ) { if ( safe_file_test(creditsFileName, (Glib::FILE_TEST_EXISTS)) ) {
FILE *f = safe_g_fopen (creditsFileName, "rt"); FILE *f = safe_g_fopen (creditsFileName, "rt");
if (f != NULL) { if (f != NULL) {
@@ -140,11 +130,7 @@ Splash::Splash () {
} }
// Tab 4: the license // Tab 4: the license
#if defined WIN32 || defined __APPLE__ std::string licenseFileName = Glib::build_filename (licensePath, "LICENSE.txt");
std::string licenseFileName = Glib::build_filename (argv0, "LICENSE.txt");
#else
std::string licenseFileName = Glib::build_filename (LICENCE_SEARCH_PATH, "LICENSE.txt");
#endif
if ( safe_file_test(licenseFileName, (Glib::FILE_TEST_EXISTS)) ) { if ( safe_file_test(licenseFileName, (Glib::FILE_TEST_EXISTS)) ) {
FILE *f = safe_g_fopen (licenseFileName, "rt"); FILE *f = safe_g_fopen (licenseFileName, "rt");
if (f != NULL) { if (f != NULL) {

View File

@@ -1,4 +0,0 @@
#!/bin/bash
RT_BINDIR=`dirname "$0"`
export LD_LIBRARY_PATH=${RT_BINDIR}
cd "${RT_BINDIR}" && ./rawtherapee "$@"