diff --git a/CMakeLists.txt b/CMakeLists.txt index a7e29e03a..d1893ca33 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,228 +1,250 @@ -if (WIN32) +if(WIN32) cmake_minimum_required(VERSION 2.8.4) -else (WIN32) +else() cmake_minimum_required(VERSION 2.6) -endif (WIN32) +endif() -# must stay before the 'project' command +# Must stay before the PROJECT() command: if(${CMAKE_EXTRA_GENERATOR} MATCHES "Eclipse CDT4") set(CMAKE_CXX_COMPILER_ARG1 "-std=c++11" CACHE STRING "C++ version for eclipse" FORCE) - # users building with Eclipse should set CMAKE_ECLIPSE_VERSION through the command line to their current version of Eclipse + # Users building with Eclipse should set CMAKE_ECLIPSE_VERSION through the + # command line to their current version of Eclipse: #set(CMAKE_ECLIPSE_VERSION "4.6.0" CACHE STRING "Eclipse version" FORCE) endif() PROJECT(RawTherapee) -# the default target is 'Debug' -if (CMAKE_BUILD_TYPE STREQUAL "") - set (CMAKE_BUILD_TYPE Debug CACHE STRING "One of: None Debug Release RelWithDebInfo MinSizeRel." FORCE) -endif () +# The default target is Debug: +if(CMAKE_BUILD_TYPE STREQUAL "") + set (CMAKE_BUILD_TYPE Debug CACHE STRING "One of: None Debug Release RelWithDebInfo MinSizeRel" FORCE) +endif() -string (TOUPPER ${CMAKE_BUILD_TYPE} UPPER_CMAKE_BUILD_TYPE) +string(TOUPPER ${CMAKE_BUILD_TYPE} UPPER_CMAKE_BUILD_TYPE) -# Set required C and C++ standards and check GCC version -SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11") -SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +# Set required C and C++ standards and check GCC version: +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9") message(FATAL_ERROR "Building RawTherapee requires using GCC version 4.9 or higher!") endif() -# We might want to build using the old C++ ABI, even when using a new GCC version -if (USE_OLD_CXX_ABI) +# We might want to build using the old C++ ABI, even when using a new GCC version: +if(USE_OLD_CXX_ABI) add_definitions (-D_GLIBCXX_USE_CXX11_ABI=0) endif() -if (UPPER_CMAKE_BUILD_TYPE STREQUAL "DEBUG") +if(UPPER_CMAKE_BUILD_TYPE STREQUAL "DEBUG") add_definitions (-D_DEBUG) -else () +else() add_definitions (-DNDEBUG) add_definitions (-D_DNDEBUG) -endif () +endif() message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/") -# Examples: "" = ~/.config/RawTherapee, "latesttag" = ~/.config/RawTherapee4.2, "_testing" = ~/.config/RawTherapee_testing -set (CACHE_NAME_SUFFIX "" CACHE STRING "RawTherapee's cache folder suffix") +# Cache name suffix examples: "" = ~/.config/RawTherapee, "5" = ~/.config/RawTherapee-5, "_testing" = ~/.config/RawTherapee_testing +# Use "" for stable releases and "5-dev" for anything else. +set(CACHE_NAME_SUFFIX "" CACHE STRING "RawTherapee's cache folder suffix") -# By default, we don't use specific processor target, so PROC_TARGET_NUMBER is set to 0. If can specify other values to select specific -# processor targets, which list can be found in ProcessorTargets.cmake. -set (PROC_TARGET_NUMBER 0 CACHE STRING "Selected target processor from the list above (taken from ProcessorTargets.cmake)") +# By default we don't use a specific processor target, so PROC_TARGET_NUMBER is set to 0. +# Specify other values to optimize for specific processor architecture as listed in ProcessorTargets.cmake: +set(PROC_TARGET_NUMBER 0 CACHE STRING "Selected target processor from the list above (taken from ProcessorTargets.cmake)") -# The following line set special compilation flags for RTEngine, and will be added to CMAKE_CXX_FLAGS -set (RTENGINE_CXX_FLAGS "" CACHE STRING "Special compilation flags for RTEngine") +# Set special compilation flags for rtengine which get added to CMAKE_CXX_FLAGS: +set(RTENGINE_CXX_FLAGS "" CACHE STRING "Special compilation flags for RTEngine") -#loading the processor targets list -include (ProcessorTargets.cmake) -set (PROC_LABEL "undefined" CACHE STRING "Target processor label, unused if PROC_TARGET_NUMBER = 0 or 2") -set (PROC_FLAGS "" CACHE STRING "Target processor related build/link flags") -if ((NOT(PROC_TARGET_NUMBER EQUAL 0)) AND (NOT(PROC_TARGET_NUMBER EQUAL 2))) - set (PROC_LABEL ${PROC_TARGET_${PROC_TARGET_NUMBER}_LABEL}) -endif () -if (NOT(PROC_TARGET_NUMBER EQUAL 0)) - set (PROC_FLAGS ${PROC_TARGET_${PROC_TARGET_NUMBER}_FLAGS}) -endif () -if (UNIX AND PROC_LABEL STREQUAL "undefined") +# Loads the ProcessorTargets list: +include(ProcessorTargets.cmake) +set(PROC_LABEL "undefined" CACHE STRING "Target processor label, unused if PROC_TARGET_NUMBER = 0 or 2") +set(PROC_FLAGS "" CACHE STRING "Target processor related build/link flags") +if((NOT (PROC_TARGET_NUMBER EQUAL 0)) AND (NOT (PROC_TARGET_NUMBER EQUAL 2))) + set(PROC_LABEL ${PROC_TARGET_${PROC_TARGET_NUMBER}_LABEL}) +endif() +if(NOT(PROC_TARGET_NUMBER EQUAL 0)) + set(PROC_FLAGS ${PROC_TARGET_${PROC_TARGET_NUMBER}_FLAGS}) +endif() +if(UNIX AND PROC_LABEL STREQUAL "undefined") execute_process(COMMAND uname -p OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE cpu) - if ("${cpu}" STREQUAL "unknown") + if("${cpu}" STREQUAL "unknown") set(PROC_LABEL "${CMAKE_SYSTEM_PROCESSOR}") - else () - set (PROC_LABEL "${cpu}") - endif () -endif () + else() + set(PROC_LABEL "${cpu}") + endif() +endif() -# if it exists, the PROC_FORCED_LABEL value is loaded in PROC_LABEL to override the one of ProcessorTargets -if (DEFINED PROC_FORCED_LABEL) - set (PROC_LABEL ${PROC_FORCED_LABEL}) -endif (DEFINED PROC_FORCED_LABEL) +# If PROC_FORCED_LABEL exists, its value is loaded in PROC_LABEL to override the one from ProcessorTargets: +if(DEFINED PROC_FORCED_LABEL) + set(PROC_LABEL ${PROC_FORCED_LABEL}) +endif() -# adding the proc flags to the build flags +# Add the proc flags to the build flags: set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PROC_FLAGS}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PROC_FLAGS}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${PROC_FLAGS}") -#stop compile on typos like std:swap (missing colon will be detected as unused label) +# Stop compilation on typos such as std:swap (missing colon will be detected as unused label): set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=unused-label") -if (WIN32) - # we additionnally look in the MinGW path first then in the Gtkmm path, - # so if you wish to build some dependant library, you have to install them in MinGW to use them +if(WIN32) + # Add additional paths. Look in the MinGW path first, then in the Gtkmm path. + # If you wish to build some dependent libraries, you have to install them in MinGW to use them: set(CMAKE_PREFIX_PATH $ENV{MINGW_BASEPATH} $ENV{GTKMM_BASEPATH} CACHE STRING "Additional search paths") -endif (WIN32) +endif() -if (APPLE) - if (CMAKE_CXX_COMPILER MATCHES "g\\+\\+-mp-4.[5-8]" OR - CMAKE_CXX_COMPILER_ARG1 MATCHES "g\\+\\+-mp-4.[5-8]") - set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /usr/lib/libstdc++.6.dylib") - message (STATUS "CMAKE_CXX_COMPILER is MacPorts GCC.\n CMAKE_EXE_LINKER_FLAGS: ${CMAKE_EXE_LINKER_FLAGS}") - endif () -endif (APPLE) +if(APPLE) + if(CMAKE_CXX_COMPILER MATCHES "g\\+\\+-mp-4.[5-8]" OR CMAKE_CXX_COMPILER_ARG1 MATCHES "g\\+\\+-mp-4.[5-8]") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /usr/lib/libstdc++.6.dylib") + message(STATUS "CMAKE_CXX_COMPILER is MacPorts GCC.\n CMAKE_EXE_LINKER_FLAGS: ${CMAKE_EXE_LINKER_FLAGS}") + endif() +endif() -option(USE_EXPERIMENTAL_LANG_VERSIONS "Build RT with -std=c++0x" OFF) -option (BUILD_SHARED "Build rawtherapee with shared libraries" OFF) -option (WITH_BZIP "Build with Bzip2 support" ON) -option (WITH_MYFILE_MMAP "Build using memory mapped file" ON) -option (WITH_LTO "Build with link-time optimizations" OFF) -option (WITH_SAN "Build with run-time sanitizer" OFF) -option (WITH_PROF "Build with profiling instrumentation" OFF) -option (OPTION_OMP "Build with OpenMP support" ON) -option (STRICT_MUTEX "True (recommended): MyMutex will behave like POSIX Mutex; False: MyMutex will behave like POSIX RecMutex; Note: forced to ON for Debug builds" ON) -option (TRACE_MYRWMUTEX "Trace RT's custom R/W Mutex (Debug builds only); redirecting std::out to a file is strongly recommended!" OFF) -option (AUTO_GDK_FLUSH "Use gdk_flush on all gdk_thread_leave other than the GUI thread; set it ON if you experience X Server warning/errors" OFF) +option(USE_EXPERIMENTAL_LANG_VERSIONS "Build with -std=c++0x" OFF) +option(BUILD_SHARED "Build with shared libraries" OFF) +option(WITH_BZIP "Build with Bzip2 support" ON) +option(WITH_MYFILE_MMAP "Build using memory mapped file" ON) +option(WITH_LTO "Build with link-time optimizations" OFF) +option(WITH_SAN "Build with run-time sanitizer" OFF) +option(WITH_PROF "Build with profiling instrumentation" OFF) +option(OPTION_OMP "Build with OpenMP support" ON) +option(STRICT_MUTEX "True (recommended): MyMutex will behave like POSIX Mutex; False: MyMutex will behave like POSIX RecMutex; Note: forced to ON for Debug builds" ON) +option(TRACE_MYRWMUTEX "Trace custom R/W Mutex (Debug builds only); redirecting std::out to a file is strongly recommended!" OFF) +option(AUTO_GDK_FLUSH "Use gdk_flush on all gdk_thread_leave other than the GUI thread; set it ON if you experience X Server warning/errors" OFF) +#option(TARGET32BIT "Build for 32-bit architecture when ON, otherwise 64-bit. Default is OFF" OFF) -# set install directories -if (WIN32 OR APPLE) +# Set installation directories: +if(WIN32 OR APPLE) + if(BUILD_BUNDLE) + message(STATUS "You have set BUILD_BUNDLE=ON but this is not necessary - the option is forced to ON for Windows and macOS.") + endif() set (BUILD_BUNDLE ON FORCE) -endif(WIN32 OR APPLE) +endif() -if (NOT DEFINED BUNDLE_BASE_INSTALL_DIR) - set (BUNDLE_BASE_INSTALL_DIR "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}") -endif (NOT DEFINED BUNDLE_BASE_INSTALL_DIR) +if(NOT DEFINED BUNDLE_BASE_INSTALL_DIR) + if(APPLE) + set(BUNDLE_BASE_INSTALL_DIR "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MacOS") + else() + set(BUNDLE_BASE_INSTALL_DIR "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}") + endif() +endif() -if (BUILD_BUNDLE) - set (BINDIR .) - set (CMAKE_INSTALL_PREFIX "${BUNDLE_BASE_INSTALL_DIR}") -endif (BUILD_BUNDLE) +if(BUILD_BUNDLE) + set(BINDIR .) + set(CMAKE_INSTALL_PREFIX "${BUNDLE_BASE_INSTALL_DIR}") +endif() -if (NOT DEFINED BINDIR) - set (BINDIR "${CMAKE_INSTALL_PREFIX}/bin") -endif (NOT DEFINED BINDIR) +if(NOT DEFINED BINDIR) + set(BINDIR "${CMAKE_INSTALL_PREFIX}/bin") +endif() -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 DATADIR) + if(BUILD_BUNDLE) + if(APPLE) + set(DATADIR "../Resources") + else() + set(DATADIR .) + endif() + else() + set(DATADIR "${CMAKE_INSTALL_PREFIX}/share/rawtherapee") + endif() +endif() -if (NOT DEFINED LIBDIR) - if (BUILD_BUNDLE) - set (LIBDIR .) - else (BUILD_BUNDLE) +if(NOT DEFINED LIBDIR) + if(BUILD_BUNDLE) + if(APPLE) + set(LIBDIR "../Frameworks") + else() + set(LIBDIR .) + endif() + else() # Respect CMAKE_INSTALL_LIBDIR if set - if (DEFINED CMAKE_INSTALL_LIBDIR) - if (IS_ABSOLUTE "${LIBDIR}") - set (LIBDIR "${CMAKE_INSTALL_LIBDIR}") - else (IS_ABSOLUTE "${LIBDIR}") - set (LIBDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") - endif (IS_ABSOLUTE "${LIBDIR}") - else (DEFINED CMAKE_INSTALL_LIBDIR) - set (LIBDIR "${CMAKE_INSTALL_PREFIX}/lib") - endif (DEFINED CMAKE_INSTALL_LIBDIR) - endif (BUILD_BUNDLE) -endif (NOT DEFINED LIBDIR) + if(DEFINED CMAKE_INSTALL_LIBDIR) + if(IS_ABSOLUTE "${LIBDIR}") + set(LIBDIR "${CMAKE_INSTALL_LIBDIR}") + else() + set(LIBDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") + endif() + else() + set(LIBDIR "${CMAKE_INSTALL_PREFIX}/lib") + endif() + endif() +endif() -if (NOT DEFINED DOCDIR) - 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 DOCDIR) + if(BUILD_BUNDLE) + set(DOCDIR "${DATADIR}/share/doc") + else() + set(DOCDIR "${CMAKE_INSTALL_PREFIX}/share/doc/rawtherapee") + endif() +endif() -if (NOT DEFINED CREDITSDIR) - 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 CREDITSDIR) + if(BUILD_BUNDLE) + set(CREDITSDIR "${DATADIR}") + else() + set(CREDITSDIR "${CMAKE_INSTALL_PREFIX}/share/doc/rawtherapee") + endif() +endif() -if (NOT DEFINED LICENCEDIR) - if (BUILD_BUNDLE) - set (LICENCEDIR .) - else (BUILD_BUNDLE) - set (LICENCEDIR "${CMAKE_INSTALL_PREFIX}/share/doc/rawtherapee") - endif (BUILD_BUNDLE) -endif (NOT DEFINED LICENCEDIR) +if(NOT DEFINED LICENCEDIR) + if(BUILD_BUNDLE) + set(LICENCEDIR "${DATADIR}") + else() + set(LICENCEDIR "${CMAKE_INSTALL_PREFIX}/share/doc/rawtherapee") + endif() +endif() -if (NOT DEFINED DESKTOPDIR) - if (UNIX) - set (DESKTOPDIR "${CMAKE_INSTALL_PREFIX}/share/applications") - endif (UNIX) -endif (NOT DEFINED DESKTOPDIR) +if(NOT DEFINED DESKTOPDIR) + if(UNIX) + set(DESKTOPDIR "${CMAKE_INSTALL_PREFIX}/share/applications") # Absolute + #set(DESKTOPDIR "${DATADIR}/share/applications") # Relative + endif() +endif() -if (NOT DEFINED ICONSDIR) - if (UNIX) - set (ICONSDIR "${CMAKE_INSTALL_PREFIX}/share/icons") - endif (UNIX) -endif (NOT DEFINED ICONSDIR) +if(NOT DEFINED ICONSDIR) + if(UNIX) + set(ICONSDIR "${CMAKE_INSTALL_PREFIX}/share/icons") + endif() +endif() -if (NOT DEFINED APPDATADIR) - if (UNIX) - set (APPDATADIR "${CMAKE_INSTALL_PREFIX}/share/appdata") - endif (UNIX) -endif (NOT DEFINED APPDATADIR) +if(NOT DEFINED APPDATADIR) + if(UNIX) + set(APPDATADIR "${CMAKE_INSTALL_PREFIX}/share/appdata") + endif() +endif() -# 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 () +# Enforce absolute paths for non-bundle builds: +if(NOT BUILD_BUNDLE) + foreach(path BINDIR DATADIR LIBDIR DOCDIR CREDITSDIR LICENCEDIR) + if(NOT (IS_ABSOLUTE "${${path}}")) + message (FATAL_ERROR "The ${path} path has to be absolute when using -DBUILD_BUNDLE=OFF") + endif() + endforeach() +endif() -# MyMutex -if (STRICT_MUTEX OR UPPER_CMAKE_BUILD_TYPE STREQUAL "DEBUG") - add_definitions (-DSTRICT_MUTEX=1) -else (STRICT_MUTEX OR UPPER_CMAKE_BUILD_TYPE STREQUAL "DEBUG") - add_definitions (-DSTRICT_MUTEX=0) -endif (STRICT_MUTEX OR UPPER_CMAKE_BUILD_TYPE STREQUAL "DEBUG") +# MyMutex: +if(STRICT_MUTEX OR UPPER_CMAKE_BUILD_TYPE STREQUAL "DEBUG") + add_definitions(-DSTRICT_MUTEX=1) +else() + add_definitions(-DSTRICT_MUTEX=0) +endif() -# MyRWMutex -if (TRACE_MYRWMUTEX) - add_definitions (-DTRACE_MYRWMUTEX=1) -else (TRACE_MYRWMUTEX) - add_definitions (-DTRACE_MYRWMUTEX=0) -endif (TRACE_MYRWMUTEX) +# MyRWMutex: +if(TRACE_MYRWMUTEX) + add_definitions(-DTRACE_MYRWMUTEX=1) +else() + add_definitions(-DTRACE_MYRWMUTEX=0) +endif() -if (AUTO_GDK_FLUSH) - add_definitions (-DAUTO_GDK_FLUSH=1) -else (AUTO_GDK_FLUSH) - add_definitions (-DAUTO_GDK_FLUSH=0) -endif (AUTO_GDK_FLUSH) +if(AUTO_GDK_FLUSH) + add_definitions(-DAUTO_GDK_FLUSH=1) +else() + add_definitions(-DAUTO_GDK_FLUSH=0) +endif() -# check for libraries +# Check for libraries: find_package(PkgConfig) pkg_check_modules (GTK REQUIRED gtk+-3.0>=3.16) pkg_check_modules (GLIB2 REQUIRED glib-2.0>=2.44) @@ -234,121 +256,119 @@ pkg_check_modules (GIOMM REQUIRED giomm-2.4>=2.44) pkg_check_modules (GTHREAD REQUIRED gthread-2.0>=2.44) pkg_check_modules (GOBJECT REQUIRED gobject-2.0>=2.44) pkg_check_modules (SIGC REQUIRED sigc++-2.0>=2.3.1) -# NOTE: The new mechanism has been tested with BUILD_SHARED = OFF -if (WIN32) - add_definitions (-DWIN32) - add_definitions (-D_WIN32) - if (MINGW) - add_definitions (-D__MINGW32__) - endif (MINGW) - if (CMAKE_SIZEOF_VOID_P EQUAL 4) - add_definitions (-DWINVER=0x0501) - endif (CMAKE_SIZEOF_VOID_P EQUAL 4) - set (EXTRA_LIB "-lws2_32 -lshlwapi") -endif (WIN32) -# you may need lcms v1.xx for older version : pkg_check_modules (LCMS REQUIRED lcms<=1.99) -pkg_check_modules (LCMS REQUIRED lcms2>=2.6) -pkg_check_modules (EXPAT REQUIRED expat>=2.1) -pkg_check_modules (FFTW3F REQUIRED fftw3f) -pkg_check_modules (IPTCDATA REQUIRED libiptcdata) -find_package (JPEG REQUIRED) -find_package (PNG REQUIRED) -find_package (TIFF REQUIRED) -find_package (ZLIB REQUIRED) -# link witz bzip -if (WITH_BZIP) +if(WIN32) + add_definitions(-DWIN32) + add_definitions(-D_WIN32) + if(MINGW) + add_definitions(-D__MINGW32__) + endif() + if(CMAKE_SIZEOF_VOID_P EQUAL 4) + add_definitions(-DWINVER=0x0501) + endif() + set(EXTRA_LIB "-lws2_32 -lshlwapi") +endif() + +pkg_check_modules(LCMS REQUIRED lcms2>=2.6) +pkg_check_modules(EXPAT REQUIRED expat>=2.1) +pkg_check_modules(FFTW3F REQUIRED fftw3f) +pkg_check_modules(IPTCDATA REQUIRED libiptcdata) +find_package(JPEG REQUIRED) +find_package(PNG REQUIRED) +find_package(TIFF REQUIRED) +find_package(ZLIB REQUIRED) + +# Link with bzip: +if(WITH_BZIP) find_package(BZip2) - if (BZIP2_FOUND) - add_definitions (-DBZIP_SUPPORT) - set (EXTRA_INCDIR ${BZIP2_INCLUDE_DIR}) - set (EXTRA_LIB ${EXTRA_LIB} ${BZIP2_LIBRARIES}) - endif (BZIP2_FOUND) -endif (WITH_BZIP) + if(BZIP2_FOUND) + add_definitions(-DBZIP_SUPPORT) + set(EXTRA_INCDIR ${BZIP2_INCLUDE_DIR}) + set(EXTRA_LIB ${EXTRA_LIB} ${BZIP2_LIBRARIES}) + endif() +endif() -#Check for libcanberra-gtk3 (sound events on Linux) -if (UNIX AND (NOT APPLE)) - pkg_check_modules (CANBERRA-GTK REQUIRED libcanberra-gtk3) -endif (UNIX AND (NOT APPLE)) +# Check for libcanberra-gtk3 (sound events on Linux): +if(UNIX AND(NOT APPLE)) + pkg_check_modules(CANBERRA-GTK REQUIRED libcanberra-gtk3) +endif() -if (WITH_MYFILE_MMAP) - add_definitions (-DMYFILE_MMAP) -endif (WITH_MYFILE_MMAP) +if(WITH_MYFILE_MMAP) + add_definitions(-DMYFILE_MMAP) +endif() -if (WITH_LTO) - SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -flto") - SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto") - SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto") -endif (WITH_LTO) +if(WITH_LTO) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -flto") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto") + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto") +endif() -if (WITH_SAN) - SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=${WITH_SAN}") - SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=${WITH_SAN}") - SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=${WITH_SAN}") -endif (WITH_SAN) +if(WITH_SAN) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=${WITH_SAN}") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=${WITH_SAN}") + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=${WITH_SAN}") +endif() -if (WITH_PROF) - SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg") - SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg") - SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg") -endif (WITH_PROF) +if(WITH_PROF) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg") + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg") +endif() -if (OPTION_OMP) +if(OPTION_OMP) find_package(OpenMP) - if (OPENMP_FOUND) + if(OPENMP_FOUND) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS} -Werror=unknown-pragmas -Wall -Wno-unused-result -Wno-deprecated-declarations") - endif (OPENMP_FOUND) -endif (OPTION_OMP) + endif() +endif() -# find out whether we are building out of source +# Find out whether we are building out of source: get_filename_component(ABS_SOURCE_DIR "${PROJECT_SOURCE_DIR}" ABSOLUTE) get_filename_component(ABS_BINARY_DIR "${CMAKE_BINARY_DIR}" ABSOLUTE) -set (OUT_OF_SOURCE_BUILD TRUE) -if (ABS_SOURCE_DIR STREQUAL ABS_BINARY_DIR) - set (OUT_OF_SOURCE_BUILD FALSE) - message (WARNING "You are performing an in-source build. This is discouraged. For an explanation and the advantages of out-of-source builds, please refer to http://www.cmake.org/Wiki/CMake_FAQ#What_is_an_.22out-of-source.22_build.3F") -endif () +set(OUT_OF_SOURCE_BUILD TRUE) +if(ABS_SOURCE_DIR STREQUAL ABS_BINARY_DIR) + set(OUT_OF_SOURCE_BUILD FALSE) + message(WARNING "You are performing an in-source build. This is discouraged. For an explanation and the advantages of out-of-source builds, please refer to http://www.cmake.org/Wiki/CMake_FAQ#What_is_an_.22out-of-source.22_build.3F") +endif() -# XXX remove files triggering the below check to prevent every developer from -# needing manual manual work. We will remove this after some time to have a -# clean build system without file modifications in the source tree again. +# Remove files which could require manual work. +# We will remove this after some time to have a clean build system without file modifications in the source tree again. (?) set(OOSB_FILES "${PROJECT_SOURCE_DIR}/rtdata/rawtherapee.desktop" "${PROJECT_SOURCE_DIR}/rtgui/version.h" "${PROJECT_SOURCE_DIR}/rtgui/config.h" "${PROJECT_SOURCE_DIR}/AboutThisBuild.txt") -if (OUT_OF_SOURCE_BUILD) +if(OUT_OF_SOURCE_BUILD) foreach(f ${OOSB_FILES}) - file (REMOVE "${f}") - endforeach(f) -endif () + file(REMOVE "${f}") + endforeach() +endif() -# check for generated files in the source tree which should not be there when -# doing out of source builds. Without checking for this it might happen that old -# versions are used for the compilation -if (OUT_OF_SOURCE_BUILD) +# Check for generated files in the source tree which should not be there when doing an out-of-source build. +# Without checking for this it might happen that old versions are used for the compilation: +if(OUT_OF_SOURCE_BUILD) foreach(f ${OOSB_FILES}) - if (EXISTS "${f}") - message (SEND_ERROR "Generated \"${f}\" found inside the source tree. Please remove it as it is a relic of the old build system and prevents valid compilation now.") - endif () - endforeach(f) -endif () + if(EXISTS "${f}") + message(SEND_ERROR "Generated \"${f}\" found inside the source tree. Please remove it as it is a relic of the old build system and prevents valid compilation now.") + endif() + endforeach() +endif() -## BEGIN: Create AboutThisBuild.txt and other version-dependent files. -# set the bit number information of the platform -if (CMAKE_SIZEOF_VOID_P EQUAL 4) +### Start generating AboutThisBuild.txt +# Set the platform bit-depth: +if(CMAKE_SIZEOF_VOID_P EQUAL 4) set(PROC_BIT_DEPTH 32 bits) -elseif (CMAKE_SIZEOF_VOID_P EQUAL 8) +elseif() set(PROC_BIT_DEPTH 64 bits) -endif (CMAKE_SIZEOF_VOID_P EQUAL 4) +endif() -# Get comiler name and version -# only cmake > 2.8.7 knows CMAKE_*_COMPILER_VERSION -if (CMAKE_VERSION VERSION_GREATER 2.8.7) +# Get compiler name and version. +# Only CMake > 2.8.7 knows CMAKE_*_COMPILER_VERSION +if(CMAKE_VERSION VERSION_GREATER 2.8.7) get_filename_component(COMPILER_INFO ${CMAKE_C_COMPILER} NAME_WE) set(COMPILER_INFO "${COMPILER_INFO} ${CMAKE_C_COMPILER_VERSION}") -else () +else() execute_process(COMMAND gcc -dumpversion OUTPUT_VARIABLE GCC_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) set(COMPILER_INFO "gcc ${GCC_VERSION}") -endif () +endif() -# Get c++ and linker flags for rtengine (the gui's c++ flags may have less flags) +# Get C++ and linker flags for rtengine (the GUI's C++ flags may have fewer flags): set(CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${UPPER_CMAKE_BUILD_TYPE}} ${RTENGINE_CXX_FLAGS}") set(LFLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_${UPPER_CMAKE_BUILD_TYPE}}") @@ -362,24 +382,24 @@ set(ABOUT_COMMAND_WITH_ARGS ${CMAKE_COMMAND} -DOPTION_OMP:STRING=${OPTION_OMP} -DWITH_MYFILE_MMAP:STRING=${WITH_MYFILE_MMAP}) -if (WIN32) +if(WIN32) list(APPEND ABOUT_COMMAND_WITH_ARGS -DSYSTEM:STRING=Windows -DCXX_FLAGS:STRING="${CXX_FLAGS}" -DLFLAGS:STRING="${LFLAGS}" -DCOMPILER_INFO:STRING="${COMPILER_INFO}" -DCMAKE_INSTALL_PREFIX:STRING="${CMAKE_INSTALL_PREFIX}" -DBIT_DEPTH:STRING="${CMAKE_SIZEOF_VOID_P}") -elseif (APPLE) +elseif(APPLE) list(APPEND ABOUT_COMMAND_WITH_ARGS -DSYSTEM:STRING=Apple -DCXX_FLAGS:STRING=${CXX_FLAGS} -DLFLAGS:STRING=${LFLAGS} -DCOMPILER_INFO:STRING=${COMPILER_INFO}) -else (WIN32) +else() list(APPEND ABOUT_COMMAND_WITH_ARGS -DSYSTEM:STRING=Linux -DCXX_FLAGS:STRING=${CXX_FLAGS} -DLFLAGS:STRING=${LFLAGS} -DCOMPILER_INFO:STRING=${COMPILER_INFO}) -endif (WIN32) +endif() list(APPEND ABOUT_COMMAND_WITH_ARGS -P "${PROJECT_SOURCE_DIR}/UpdateInfo.cmake") @@ -387,21 +407,29 @@ add_custom_target(UpdateInfo ALL COMMAND ${ABOUT_COMMAND_WITH_ARGS} COMMENT "Creating AboutThisBuild.txt and other version-dependent files") -## END: Generating AboutThisBuild.txt +### End generating AboutThisBuild.txt -install (FILES AUTHORS.txt DESTINATION "${CREDITSDIR}") -install (FILES LICENSE.txt DESTINATION "${LICENCEDIR}") -install (FILES "${CMAKE_BINARY_DIR}/AboutThisBuild.txt" DESTINATION "${CREDITSDIR}") -install (FILES RELEASE_NOTES.txt DESTINATION "${CREDITSDIR}" OPTIONAL) -if (WIN32) - install (DIRECTORY "licenses" DESTINATION "${LICENCEDIR}") -endif (WIN32) -if (UNIX) - install (FILES "${PROJECT_SOURCE_DIR}/doc/manpage/rawtherapee.1" DESTINATION "${CMAKE_INSTALL_PREFIX}/share/man/man1") - install (FILES rawtherapee.appdata.xml DESTINATION "${APPDATADIR}") -endif (UNIX) +install(FILES AUTHORS.txt DESTINATION "${CREDITSDIR}") +install(FILES LICENSE.txt DESTINATION "${LICENCEDIR}") +install(FILES "${CMAKE_BINARY_DIR}/AboutThisBuild.txt" DESTINATION "${CREDITSDIR}") +install(FILES RELEASE_NOTES.txt DESTINATION "${CREDITSDIR}" OPTIONAL) + +# The standard location for man pages in Linux is /usr/share/man +# Use "manpath" to see the search paths for man pages on your system. +if(UNIX OR WIN32) + install(FILES "${PROJECT_SOURCE_DIR}/doc/manpage/rawtherapee.1" DESTINATION "${CMAKE_INSTALL_PREFIX}/share/man/man1") +endif() + +if(WIN32) + install(DIRECTORY "licenses" DESTINATION "${LICENCEDIR}") +endif() + +if(UNIX) + install(FILES rawtherapee.appdata.xml DESTINATION "${APPDATADIR}") +endif() + +add_subdirectory(rtexif) +add_subdirectory(rtengine) +add_subdirectory(rtgui) +add_subdirectory(rtdata) -add_subdirectory (rtexif) -add_subdirectory (rtengine) -add_subdirectory (rtgui) -add_subdirectory (rtdata) diff --git a/rtdata/CMakeLists.txt b/rtdata/CMakeLists.txt index 5967bd70a..0bb356172 100644 --- a/rtdata/CMakeLists.txt +++ b/rtdata/CMakeLists.txt @@ -48,10 +48,6 @@ install (DIRECTORY ${IMAGESDIR} DESTINATION "${DATADIR}" FILES_MATCHING PATTERN install (DIRECTORY ${IMAGESDIR} DESTINATION "${DATADIR}" FILES_MATCHING PATTERN "*.png") install (FILES ${OPTIONSFILE} DESTINATION "${DATADIR}" PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ RENAME options) -if (WIN32) - install (FILES "${PROJECT_SOURCE_DIR}/doc/manpage/rawtherapee.1" DESTINATION "${CMAKE_INSTALL_PREFIX}/share/man/man1") -endif (WIN32) - if (APPLE) # CMake escapes first item quote character. Do not remove 'DUMMY_VARIABLE='. set (MACOSX_BUNDLE_COMMAND DUMMY_VARIABLE= diff --git a/tools/osx/executable_loader.in b/tools/osx/executable_loader.in index 5f1911edb..535d37ec1 100644 --- a/tools/osx/executable_loader.in +++ b/tools/osx/executable_loader.in @@ -1,31 +1,47 @@ -#!/bin/bash +#!/usr/bin/env bash -cwd="$(cd "$(dirname "$0")"; pwd)" +cd "$(dirname "$0")" || exit 1 + +cwd="$(pwd)" app="${cwd%/Contents/*}" -etc="${cwd}"/etc +lib="${app}/Contents/Frameworks" +resources="${app}/Contents/Resources" +etc="${resources}"/etc -# for different os x versions -# see https://github.com/Beep6581/RawTherapee/issues/1779 -cups_dir=/tmp/RT4 -install -d ${cups_dir} -cp -f /usr/lib/libcups.2.dylib ${cups_dir} +### Pending deletion: +# See https://github.com/Beep6581/RawTherapee/issues/1779 +# cups_dir=/tmp/RT5 +# install -d "${cups_dir}" +# cp -f /usr/lib/libcups.2.dylib "${cups_dir}" +# export DYLD_LIBRARY_PATH="${lib}:${cups_dir}" -export DYLD_LIBRARY_PATH="${cwd}"/lib:${cups_dir} -export GTK_EXE_PREFIX="${cwd}" -export GTK_DATA_PREFIX="${cwd}" -export GTK_IM_MODULE_FILE="${etc}"/gtk-2.0/gtk.immodules -export GDK_PIXBUF_MODULE_FILE="${etc}"/gtk-2.0/gdk-pixbuf.loaders -export XDG_DATA_DIRS="${cwd}"/share -export PANGO_RC_FILE="${etc}"/pango/pangorc +# export GTK_EXE_PREFIX="${resources}" +# export GTK_DATA_PREFIX="${resources}" +# export XDG_DATA_DIRS="${resources}/share" +# export GTK_IM_MODULE_FILE="${etc}/gtk-3.0/gtk.immodules" -# environment variables for X11 backend -if test -d "${etc}"/fonts; then - export FONTCONFIG_PATH="${etc}"/fonts -fi +export DYLD_LIBRARY_PATH="${lib}" -# strip out system argument -case $1 in -psn_*) shift;; esac +export GTK_PATH="${lib}/gtk-3.0/3.0.0" +export XDG_DATA_HOME="${resources}/share" +export GSETTINGS_SCHEMA_DIR="${resources}/share/glib-2.0/schemas" +export GDK_PIXBUF_MODULE_FILE="${etc}/gtk-3.0/gdk-pixbuf.loaders" +export GDK_PIXBUF_MODULEDIR="${lib}/gdk-pixbuf-2.0/2.10.0/loaders" + +export RT_SETTINGS="${HOME}/Library/Application Support/RawTherapee/config" +export RT_CACHE="${HOME}/Library/Application Support/RawTherapee/cache" + +### Pending deletion: +# Environment variables for X11 backend +#if [[ -d ${etc}/fonts ]]; then +# export FONTCONFIG_PATH="${etc}/fonts" +#fi + +# Strip out system argument +case "$1" in + -psn_*) shift ;; +esac ln -sf "${app}" /tmp -exec "${cwd}"/rawtherapee-bin "$@" +exec "${cwd}/rawtherapee-bin" "$@" diff --git a/tools/osx/libiconv_1.15_rt.patch b/tools/osx/libiconv_1.15_rt.patch new file mode 100644 index 000000000..ca434154b --- /dev/null +++ b/tools/osx/libiconv_1.15_rt.patch @@ -0,0 +1,30 @@ +diff --git a/lib/iconv.c b/lib/iconv.c +index 31853a7..630a498 100644 +--- a/lib/iconv.c ++++ b/lib/iconv.c +@@ -611,4 +611,25 @@ strong_alias (libiconv, iconv) + strong_alias (libiconv_close, iconv_close) + #endif + ++#undef iconv_open ++#undef iconv ++#undef iconv_close ++ ++LIBICONV_DLL_EXPORTED iconv_t iconv_open (const char* tocode, const char* fromcode) ++{ ++ return libiconv_open(tocode, fromcode); ++} ++ ++LIBICONV_DLL_EXPORTED size_t iconv (iconv_t icd, ++ ICONV_CONST char * * inbuf, size_t *inbytesleft, ++ char * * outbuf, size_t *outbytesleft) ++{ ++ return libiconv(icd, inbuf, inbytesleft, outbuf, outbytesleft); ++} ++ ++LIBICONV_DLL_EXPORTED int iconv_close (iconv_t icd) ++{ ++ return libiconv_close(icd); ++} ++ + #endif diff --git a/tools/osx/macosx_bundle.sh b/tools/osx/macosx_bundle.sh index 89e0c23b0..26cf87250 100644 --- a/tools/osx/macosx_bundle.sh +++ b/tools/osx/macosx_bundle.sh @@ -1,17 +1,26 @@ -#!/bin/bash +#!/usr/bin/env bash -# Required variables -# ------------------ -# these are very important variables. Must be set into rtdata/CMakeLists.txt! +# Required variables, must be set in rtdata/CMakeLists.txt # - PROJECT_NAME -# - PROJECT_SOURCE_DIR # - PROJECT_VERSION (if without git) +# - PROJECT_SOURCE_DIR # - CMAKE_BUILD_TYPE # - PROC_BIT_DEPTH # - GTK_PREFIX -function message { - printf '\e[34m-- %s\e[m\n' "$*" +# Formatting +fNormal="$(tput sgr0)" +fBold="$(tput bold)" +# Colors depend upon the user's terminal emulator color scheme - what is readable for you may be not readable for someone else. +fMagenta="$(tput setaf 5)" +fRed="$(tput setaf 1)" + +function msg { + printf "\n${fBold}-- %s${fNormal}\n" "${@}" +} + +function msgError { + printf "\n${fBold}Error:${fNormal}\n%s\n" "${@}" } function GetDependencies { @@ -25,14 +34,14 @@ function CheckLink { done } -# source check -if test ! -d "${CMAKE_BUILD_TYPE}"; then - printf "\e[31m${PWD}/${CMAKE_BUILD_TYPE} directory is not found. Please execute 'make install' first.\e[m\n" +# Source check +if [[ ! -d "${CMAKE_BUILD_TYPE}" ]]; then + msgError "${PWD}/${CMAKE_BUILD_TYPE} folder does not exist. Please execute 'make install' first." exit 1 fi -# update project version -if test -x "$(which git)" -a -d "${PROJECT_SOURCE_DIR}/.git"; then +# Update project version +if [[ -x "$(which git)" && -d "${PROJECT_SOURCE_DIR}/.git" ]]; then ### This section is copied from tools/generateReleaseInfo # Get version description. # Depending on whether you checked out a branch (dev) or a tag (release), @@ -62,25 +71,11 @@ if test -x "$(which git)" -a -d "${PROJECT_SOURCE_DIR}/.git"; then fi -# if not specify CMAKE_OSX_DEPLOYMENT_TARGET when compiling, -# 'MINIMUM_VERSION' will be used host OS X version. -MINIMUM_SYSTEM_VERSION="$(otool -l "${CMAKE_BUILD_TYPE}"/rawtherapee | grep -A2 'LC_VERSION_MIN_MACOSX' | awk '$1 ~ /version/ { printf $2 }')" -if test ! -n "${MINIMUM_SYSTEM_VERSION}"; then +MINIMUM_SYSTEM_VERSION="$(otool -l "${CMAKE_BUILD_TYPE}"/MacOS/rawtherapee | grep -A2 'LC_VERSION_MIN_MACOSX' | awk '$1 ~ /version/ { printf $2 }')" +if [[ -z "${MINIMUM_SYSTEM_VERSION}" ]]; then MINIMUM_SYSTEM_VERSION="$(sw_vers -productVersion | cut -d. -f-2)" fi -# check for pango-querymodules. Pango 1.38.0 and above do not include it. -# https://github.com/Homebrew/homebrew/issues/44764#issuecomment-146795820 -PangoVer="$(brew list --versions pango)" -PangoVer="${PangoVer//./}" -# Only check the first 4 digits, so that "1.36.99" (13699) doesn't test greater than "1.38.0" (1380) -PangoVer="${PangoVer:0:4}" -if [[ "$PangoVer" -ge "1380" ]]; then - ExistPangoQuerymodules="false" -else - ExistPangoQuerymodules="true" -fi - case ${PROC_BIT_DEPTH} in 64) arch=x86_64;; 32) arch=i386;; @@ -97,127 +92,133 @@ GTK_PREFIX: ${GTK_PREFIX} PWD: ${PWD} __EOS__ -APP="${PROJECT_NAME}".app -CONTENTS="${APP}"/Contents -RESOURCES="${CONTENTS}"/Resources -MACOS="${CONTENTS}"/MacOS -LIB="${MACOS}"/lib -ETC="${MACOS}"/etc -EXECUTABLE="${MACOS}"/rawtherapee +APP="${PROJECT_NAME}.app" +CONTENTS="${APP}/Contents" +RESOURCES="${CONTENTS}/Resources" +MACOS="${CONTENTS}/MacOS" +LIB="${CONTENTS}/Frameworks" +ETC="${RESOURCES}/etc" +EXECUTABLE="${MACOS}/rawtherapee" -message "Removing old files" +msg "Removing old files:" rm -rf "${APP}" "${PROJECT_NAME}_*.dmg" -message "Creating bundle container" +msg "Creating bundle container:" install -d "${RESOURCES}" \ -"${MACOS}" \ -"${LIB}" \ -"${ETC}" + "${MACOS}" \ + "${LIB}" \ + "${ETC}" -message "Copying release files" -ditto "${CMAKE_BUILD_TYPE}" "${MACOS}" +msg "Copying release files:" +ditto "${CMAKE_BUILD_TYPE}/MacOS" "${MACOS}" +ditto "${CMAKE_BUILD_TYPE}/Resources" "${RESOURCES}" -message "Copying dependencies from ${GTK_PREFIX}" +msg "Copying dependencies from ${GTK_PREFIX}:" CheckLink "${EXECUTABLE}" -message "Copying library modules from ${GTK_PREFIX}" -ditto --arch "${arch}" {"${GTK_PREFIX}"/lib,"${LIB}"}/gdk-pixbuf-2.0 -ditto --arch "${arch}" {"${GTK_PREFIX}"/lib,"${LIB}"}/gtk-2.0 -ditto --arch "${arch}" {"${GTK_PREFIX}"/lib,"${LIB}"}/pango +msg "Copying library modules from ${GTK_PREFIX}:" +ditto --arch "${arch}" {"${GTK_PREFIX}/lib","${LIB}"}/gdk-pixbuf-2.0 +ditto --arch "${arch}" {"${GTK_PREFIX}/lib","${LIB}"}/gtk-3.0 -message "Removing static libraries and cache files" +msg "Removing static libraries and cache files:" find -E "${LIB}" -type f -regex '.*\.(a|la|cache)$' | while read; do rm "${REPLY}"; done -message "Copying configuration files from ${GTK_PREFIX}" -install -d "${ETC}"/{gtk-2.0,pango} -cp "${GTK_PREFIX}"/etc/gtk-2.0/im-multipress.conf "${ETC}"/gtk-2.0 -"${GTK_PREFIX}"/bin/gdk-pixbuf-query-loaders "${LIB}"/gdk-pixbuf-2.0/*/loaders/*.so > "${ETC}"/gtk-2.0/gdk-pixbuf.loaders -"${GTK_PREFIX}"/bin/gtk-query-immodules-2.0 "${LIB}"/gtk-2.0/*/immodules/*.so > "${ETC}"/gtk-2.0/gtk.immodules -sed -i "" -e "s|${PWD}|/tmp|" "${ETC}"/gtk-2.0/gdk-pixbuf.loaders \ -"${ETC}"/gtk-2.0/gtk.immodules -if [[ "$ExistPangoQuerymodules" = "true" ]]; then - "${GTK_PREFIX}"/bin/pango-querymodules "${LIB}"/pango/*/modules/*.so > "${ETC}"/pango/pango.modules - sed -i "" -e "s|${PWD}|/tmp|" "${ETC}"/pango/pango.modules - printf "[Pango]\nModuleFiles = /tmp/${ETC}/pango/pango.modules" > "${ETC}"/pango/pangorc -fi +msg "Copying configuration files from ${GTK_PREFIX}:" +install -d "${ETC}/gtk-3.0" +cp "${GTK_PREFIX}/etc/gtk-3.0/im-multipress.conf" "${ETC}/gtk-3.0" +"${GTK_PREFIX}/bin/gdk-pixbuf-query-loaders" "${LIB}"/gdk-pixbuf-2.0/*/loaders/*.so > "${ETC}/gtk-3.0/gdk-pixbuf.loaders" +"${GTK_PREFIX}/bin/gtk-query-immodules-3.0" "${LIB}"/gtk-3.0/*/immodules/*.so > "${ETC}/gtk-3.0/gtk.immodules" +sed -i "" -e "s|${PWD}|/tmp|" "${ETC}/gtk-3.0/gdk-pixbuf.loaders" "${ETC}/gtk-3.0/gtk.immodules" -message "Copying shared files from ${GTK_PREFIX}" -cp -R "${GTK_PREFIX}"/share/mime "${MACOS}"/share -# gtk themes -ditto {"${GTK_PREFIX}","${MACOS}"}/share/themes/Mac/gtk-2.0-key/gtkrc -ditto {"${GTK_PREFIX}","${MACOS}"}/share/themes/Clearlooks/gtk-2.0/gtkrc -install -d "${MACOS}"/share/themes/Raleigh/gtk-2.0 -(cd "${MACOS}"/share/themes/Raleigh/gtk-2.0 && ln -s ../../Clearlooks/gtk-2.0/gtkrc) +ditto {"${GTK_PREFIX}","${RESOURCES}"}/share/glib-2.0/schemas +"${GTK_PREFIX}/bin/glib-compile-schemas" "${RESOURCES}/share/glib-2.0/schemas" + +msg "Copying shared files from ${GTK_PREFIX}:" +ditto {"${GTK_PREFIX}","${RESOURCES}"}/share/mime +# GTK3 themes +ditto {"${GTK_PREFIX}","${RESOURCES}"}/share/themes/Mac/gtk-3.0/gtk-keys.css +ditto {"${GTK_PREFIX}","${RESOURCES}"}/share/themes/Default/gtk-3.0/gtk-keys.css +# Adwaita icons +iconfolders=("16x16/actions" "16x16/devices" "16x16/mimetypes" "16x16/places" "16x16/status" "48x48/devices") +for f in "${iconfolders[@]}"; do + ditto {"${GTK_PREFIX}","${RESOURCES}"}/share/icons/Adwaita/"$f" +done +ditto {"${GTK_PREFIX}","${RESOURCES}"}/share/icons/Adwaita/index.theme +"${GTK_PREFIX}/bin/gtk-update-icon-cache-3.0" "${RESOURCES}/share/icons/Adwaita" + +### Pending deletion: # fontconfig files (X11 backend only) -if otool -L "${EXECUTABLE}" | grep -sq 'libgtk-x11-2.0'; then - message "Installing fontconfig files (Your library is X11 backend. 'FONTCONFIG_PATH' will be set by executable loader.)" - cp -RL "${GTK_PREFIX}"/etc/fonts "${ETC}" -fi +# if otool -L "${EXECUTABLE}" | grep -sq 'libgtk-x11-2.0'; then +# msg "Installing fontconfig files (Using X11 backend. FONTCONFIG_PATH will be set by executable loader.)" +# cp -RL "${GTK_PREFIX}/etc/fonts" "${ETC}" +# fi - - -# install names +# Install names find -E "${MACOS}" -type f -regex '.*/(rawtherapee|.*\.(dylib|so))' | while read x; do - message "Modifying install names: ${x}" + msg "Modifying install names: ${x}" { # id - case ${x} in *.dylib) echo " install_name_tool -id '@rpath/$(basename "${x}")' '${x}'";; esac - # names - GetDependencies "${x}" | while read y; do - echo " install_name_tool -change '${y}' '@rpath/$(basename "${y}")' '${x}'" - done -} | bash -v + case ${x} in *.dylib) echo " install_name_tool -id '@rpath/$(basename "${x}")' '${x}'";; esac + # names + GetDependencies "${x}" | while read y; do + echo " install_name_tool -change '${y}' '@rpath/$(basename "${y}")' '${x}'" + done + } | bash -v done -message "Registering @loader_path into the executable" +msg "Registering @loader_path into the executable:" echo " install_name_tool -add_rpath @loader_path/lib '${EXECUTABLE}'" | bash -v +msg "Installing required application bundle files:" +PROJECT_SOURCE_DATA_DIR="${PROJECT_SOURCE_DIR}/tools/osx" - -message "Installing required application bundle files" -PROJECT_SOURCE_DATA_DIR="${PROJECT_SOURCE_DIR}"/tools/osx -# executable loader -# note: executable is renamed to 'rawtherapee-bin'. -mv "${MACOS}"/rawtherapee{,-bin} -install -m 0755 "${PROJECT_SOURCE_DATA_DIR}"/executable_loader.in "${MACOS}"/rawtherapee -# app bundle resources -cp "${PROJECT_SOURCE_DATA_DIR}"/{rawtherapee,profile}.icns "${RESOURCES}" -cp "${PROJECT_SOURCE_DATA_DIR}"/PkgInfo "${CONTENTS}" -install -m 0644 "${PROJECT_SOURCE_DATA_DIR}"/Info.plist.in "${CONTENTS}"/Info.plist +# Executable loader +# Note: executable is renamed to 'rawtherapee-bin'. +mv "${MACOS}/rawtherapee" "${MACOS}/rawtherapee-bin" +install -m 0755 "${PROJECT_SOURCE_DATA_DIR}/executable_loader.in" "${MACOS}/rawtherapee" +# App bundle resources +cp "${PROJECT_SOURCE_DATA_DIR}/"{rawtherapee,profile}.icns "${RESOURCES}" +cp "${PROJECT_SOURCE_DATA_DIR}/PkgInfo" "${CONTENTS}" +install -m 0644 "${PROJECT_SOURCE_DATA_DIR}/Info.plist.in" "${CONTENTS}/Info.plist" sed -i "" -e "s|@version@|${PROJECT_FULL_VERSION}| s|@shortVersion@|${PROJECT_VERSION}| s|@arch@|${arch}|" \ -"${CONTENTS}"/Info.plist -plutil -convert binary1 "${CONTENTS}"/Info.plist + "${CONTENTS}/Info.plist" +plutil -convert binary1 "${CONTENTS}/Info.plist" function CreateDmg { - local srcdir="$(mktemp -dt $$)" + local srcDir="$(mktemp -dt $$)" - message "Preparing disk image sources at ${srcdir}" - mv "${APP}" "${srcdir}" - cp AboutThisBuild.txt "${srcdir}" - ln -s /Applications "${srcdir}" + msg "Preparing disk image sources at ${srcDir}:" + cp -R "${APP}" "${srcDir}" + cp AboutThisBuild.txt "${srcDir}" + ln -s /Applications "${srcDir}" - # web bookmarks + # Web bookmarks function CreateWebloc { - defaults write "${srcdir}/$1" URL "$2" - mv "${srcdir}/$1".{plist,webloc} + defaults write "${srcDir}/$1" URL "$2" + mv "${srcDir}/$1".{plist,webloc} } - CreateWebloc 'RawTherapee Blog' 'http://www.rawtherapee.com' - CreateWebloc 'Online Manual' 'http://rawpedia.rawtherapee.com/' + CreateWebloc 'Website' 'http://www.rawtherapee.com/' + CreateWebloc 'Manual' 'http://rawpedia.rawtherapee.com/' - # disk image name + # Disk image name dmg_name="${PROJECT_NAME// /_}_OSX_${MINIMUM_SYSTEM_VERSION}_${PROC_BIT_DEPTH}_${PROJECT_FULL_VERSION}" - if ! echo "${CMAKE_BUILD_TYPE}" | grep -sqi "release"; then - dmg_name="${dmg_name}_$(echo ${CMAKE_BUILD_TYPE} | tr '[:upper:]' '[:lower:]')" + lower_build_type="$(tr '[:upper:]' '[:lower:]' <<< "$CMAKE_BUILD_TYPE")" + if [[ ${lower_build_type} != release ]]; then + dmg_name="${dmg_name}_${lower_build_type}" fi - message "Creating disk image" - hdiutil create -format UDBZ -srcdir "${srcdir}" -volname "${PROJECT_NAME}_${PROJECT_FULL_VERSION}" "${dmg_name}".dmg + msg "Creating disk image:" + hdiutil create -format UDBZ -srcdir "${srcDir}" -volname "${PROJECT_NAME}_${PROJECT_FULL_VERSION}" "${dmg_name}.dmg" - message "Removing disk image caches" - rm -rf "${srcdir}" + # Zip disk image for redistribution + zip "${dmg_name}.zip" "${dmg_name}.dmg" AboutThisBuild.txt + rm "${dmg_name}.dmg" + + msg "Removing disk image caches:" + rm -rf "${srcDir}" } CreateDmg