Diff of /CMakeLists.txt [17656d] .. [6f8fa7]  Maximize  Restore

Switch to side-by-side view

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,10 +1,26 @@
 
-# require at least cmake 2.8
-cmake_minimum_required(VERSION 2.8 FATAL_ERROR )
+# require at least cmake 3.1
+cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR )
+
+# prevent in-tree building
+if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
+    message(FATAL_ERROR "In-source builds are not allowed.")
+endif()
 
 if(COMMAND cmake_policy)
   cmake_policy(SET CMP0003 NEW)
 endif(COMMAND cmake_policy)
+
+if(APPLE)
+  set(CMAKE_OSX_SYSROOT macosx10.12)
+  set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9")
+  if (MAC_SELF_CONTAINED_BUNDLE)
+      set(CMAKE_LIBRARY_PATH ${CMAKE_SOURCE_DIR}/mac/ExternalPrograms/repository/lib)
+      set(CMAKE_INCLUDE_PATH ${CMAKE_SOURCE_DIR}/mac/ExternalPrograms/repository/include ${CMAKE_SOURCE_DIR}/mac/ExternalPrograms/repository/bin)
+  endif(MAC_SELF_CONTAINED_BUNDLE)
+  # for FindOpenMP
+  set(CMAKE_REQUIRED_INCLUDES ${CMAKE_SOURCE_DIR}/mac/ExternalPrograms/repository/include)
+endif(APPLE)
 
 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMakeModules )
 
@@ -39,8 +55,8 @@
 project(hugin)
 
 # version
-set(V_MAJOR 2013)
-set(V_MINOR 1)
+set(V_MAJOR 2016)
+set(V_MINOR 3)
 set(V_PATCH 0)
 
 #
@@ -48,9 +64,9 @@
 #
 
 IF(EXISTS ${PROJECT_SOURCE_DIR}/.hg)
-  FIND_PROGRAM(_hg hg)
-  IF(NOT ${_hg} MATCHES "-NOTFOUND")
-    EXECUTE_PROCESS(COMMAND ${_hg} summary WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" OUTPUT_VARIABLE _release OUTPUT_STRIP_TRAILING_WHITESPACE)
+  FIND_PACKAGE(Hg)
+  IF(HG_FOUND)
+    EXECUTE_PROCESS(COMMAND ${HG_EXECUTABLE} summary WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" OUTPUT_VARIABLE _release OUTPUT_STRIP_TRAILING_WHITESPACE)
     foreach(_v_l ${_release})
       if(_v_l MATCHES "^.*: *[^0-9]*\([0-9]+\):\([a-z0-9]+\)")
         set(CPACK_PACKAGE_VERSION_PATCH ${CMAKE_MATCH_1})
@@ -70,6 +86,7 @@
     MESSAGE(FATAL_ERROR "Hugin subversion repository is not up to date. The development happens now in mercurial repository. Please switch to mercurial. Sorry for the inconsistency")
   ENDIF()
 
+  SET(CPACK_PACKAGE_VERSION_PATCH ${V_PATCH})
   SET(HUGIN_PACKAGE_VERSION ${V_MAJOR}.${V_MINOR}.${V_PATCH})
   SET(HUGIN_WC_REVISION 0)
   FILE(READ "${PROJECT_SOURCE_DIR}/rev.txt" HUGIN_WC_REVISION)
@@ -78,19 +95,6 @@
   SET(HUGIN_DEVELOPMENT_VERSION 0)
 ENDIF()
 
-#
-# Check for mercurial and update changelog
-#
-IF (EXISTS ${PROJECT_SOURCE_DIR}/.hg)
-  IF (UPDATE_CHANGELOG)
-   FIND_PROGRAM(_hg hg)
-   EXECUTE_PROCESS(COMMAND ${_hg} log --follow --style ${PROJECT_SOURCE_DIR}/Changelog.style
-   WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
-   OUTPUT_FILE ${PROJECT_SOURCE_DIR}/ChangeLog)
-   MESSAGE("-- New ChangeLog generated")
-  ENDIF (UPDATE_CHANGELOG)
-ENDIF (EXISTS ${PROJECT_SOURCE_DIR}/.hg)
-
 # version to display
 IF (HUGIN_DEVELOPMENT_VERSION EQUAL 1)
   set(DISPLAY_VERSION "Pre-Release ${V_MAJOR}.${V_MINOR}.${V_PATCH}.${HUGIN_WC_REVISION}")
@@ -107,7 +111,6 @@
 
 include_directories( ${CMAKE_BINARY_DIR}/src )
 include_directories( ${CMAKE_SOURCE_DIR}/src/hugin_base )
-include_directories( ${CMAKE_SOURCE_DIR}/src/foreign/vigra )
 include_directories( ${CMAKE_SOURCE_DIR}/src/celeste )
 include_directories( ${CMAKE_BINARY_DIR}/src/celeste )
 include_directories( ${CMAKE_SOURCE_DIR}/src )
@@ -115,17 +118,7 @@
 # this function is not available on some systems, notably FreeBSD and Windows
 include(CheckFunctionExists)
 set(CMAKE_REQUIRED_LIBRARIES -lm)
-check_function_exists(log2 HAVE_LOG2)
-# use messages only for debug - on Windows they are extremely intrusive
-# message("LOG2 ${HAVE_LOG2}")
-
-IF (EXISTS ${PROJECT_SOURCE_DIR}/.svn)
-  IF (UPDATE_CHANGELOG)
-    EXECUTE_PROCESS(COMMAND "svn2cl" "--group-by-day" "--include-rev" "--linelen=78"
-      "--output=${PROJECT_SOURCE_DIR}/ChangeLog" "${PROJECT_SOURCE_DIR}" )
-  ENDIF (UPDATE_CHANGELOG)
-ENDIF (EXISTS ${PROJECT_SOURCE_DIR}/.svn)
-
+check_function_exists(log1p HAVE_LOG1P)
 
 #
 # find dependencies
@@ -158,14 +151,11 @@
 
   # wxWidgets
   IF(NOT wxWidgets_ROOT_SUFFIX)
-    SET( wxWidgets_ROOT_SUFFIX 2.8.10 CACHE STRING "version of wxWidgets." FORCE )
+    SET( wxWidgets_ROOT_SUFFIX 3.0.0 CACHE STRING "version of wxWidgets." FORCE )
   ENDIF(NOT wxWidgets_ROOT_SUFFIX)
-
-  SET(wxWidgets_ROOT_DIR ${SOURCE_BASE_DIR}/wxWidgets-${wxWidgets_ROOT_SUFFIX})
-  # GLEW moved to FildGLEW.cmake module
-  # SET(GLEW_INCLUDE_DIR ${SOURCE_BASE_DIR}/glew/include)
-  # for dynamic build, it's glew32.lib and the dll must be copied into hugin's bin folder
-  # SET(GLEW_LIBRARIES ${SOURCE_BASE_DIR}/glew/lib/glew32s.lib)
+  IF(NOT wxWidgets_ROOT_DIR)
+    SET(wxWidgets_ROOT_DIR ${SOURCE_BASE_DIR}/wxWidgets-${wxWidgets_ROOT_SUFFIX})
+  ENDIF()
 ENDIF(WIN32)
 
 ##
@@ -173,21 +163,23 @@
 ##
 #  This must come before FINDs for tiff, jpeg, png, zlib to enable
 #  finding the wxWidgets distributions of those packages (Win32 only).
-SET(wxWidgets_USE_LIBS base core aui xrc html xml adv gl net)
+SET(wxWidgets_USE_LIBS base core aui xrc html xml adv gl net qa)
 FIND_PACKAGE(wxWidgets REQUIRED)
 
-# hugin requires wxwidgets 2.7.0 or above
+# hugin requires wxwidgets 3.0 or above
 IF (UNIX)
   EXEC_PROGRAM(sh ARGS "${wxWidgets_CONFIG_EXECUTABLE} --version" OUTPUT_VARIABLE wxWidgets_VERSION)
   STRING(REGEX REPLACE "^([0-9]+\\.[0-9]+)\\..*" "\\1"  wxWidgets_VERSION ${wxWidgets_VERSION})
-  IF(wxWidgets_VERSION STREQUAL "2.5")
+  IF(wxWidgets_VERSION VERSION_LESS "3.0")
     SET(wxWidgets_FOUND FALSE)
-    MESSAGE("wxWidgets 2.5.x not supported")
-  ENDIF(wxWidgets_VERSION STREQUAL "2.5")
-  IF(wxWidgets_VERSION STREQUAL "2.6")
+    MESSAGE("At least wxWidgets 3.0 is required")
+  ENDIF()
+  # Ubuntu has 2 different devel packages, we need the GUI version
+  EXEC_PROGRAM(sh ARGS "${wxWidgets_CONFIG_EXECUTABLE} --query-toolkit" OUTPUT_VARIABLE wxWidgets_TOOLKIT)
+  IF(wxWidgets_TOOLKIT STREQUAL "base")
     SET(wxWidgets_FOUND FALSE)
-    MESSAGE("wxWidgets 2.6.x not supported")
-  ENDIF(wxWidgets_VERSION STREQUAL "2.6")
+    MESSAGE("wxWidgets is as non-GUI package configured. Check you wxWidgets installation (maybe wxgtkXX-devel is missing)")
+  ENDIF()
 ENDIF (UNIX)
 
 IF(NOT wxWidgets_FOUND)
@@ -207,26 +199,51 @@
 INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
 INCLUDE_DIRECTORIES(${PNG_INCLUDE_DIR})
 
+IF(WIN32 AND NOT HUGIN_SHARED)
+IF(NOT ${WX_jpeg} MATCHES ${JPEG_LIBRARIES_RELEASE})
+MESSAGE(FATAL_ERROR "Using different libjpeg and wxjpeg. This does not work with static libs. Use wxjpeg for libjpeg")
+ENDIF()
+IF(NOT ${WX_zlib} MATCHES ${ZLIB_LIBRARIES_RELEASE})
+MESSAGE(FATAL_ERROR "Using different libzlib and wxzlib. This does not work with static libs. Use wxjpeg for libzlib")
+ENDIF()
+IF(NOT ${WX_png} MATCHES ${PNG_LIBRARIES_RELEASE})
+MESSAGE(FATAL_ERROR "Using different libpng and wxpng. This does not work with static libs. Use wxjpeg for libpng")
+ENDIF()
+IF(NOT ${WX_tiff} MATCHES ${TIFF_LIBRARIES_RELEASE})
+MESSAGE(FATAL_ERROR "Using different libtiff and wxtiff. This does not work with static libs. Use wxtiff for libtiff")
+ENDIF()
+
+ENDIF()
+
 FIND_PACKAGE(OpenEXR REQUIRED)
 include_directories(${OPENEXR_INCLUDE_DIR})
 
-FIND_PACKAGE(Exiv2 REQUIRED)
+FIND_PACKAGE(VIGRA 1.9.0 REQUIRED)
+include_directories(${VIGRA_INCLUDE_DIR})
+
+FIND_PACKAGE(EXIV2 REQUIRED)
 INCLUDE_DIRECTORIES(${EXIV2_INCLUDE_DIR})
 
 ## OpenGL and GLEW
 
-FIND_PACKAGE(OpenGL)
-FIND_PACKAGE(GLUT)
-FIND_PACKAGE(GLEW)
-IF(NOT OPENGL_FOUND)
-  MESSAGE("OpenGL was not found, hugin disabled")
-ENDIF(NOT OPENGL_FOUND)
-IF(GLEW_FOUND)
-  INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
+FIND_PACKAGE(OpenGL REQUIRED)
+INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
+SET(OPENGL_GLEW_LIBRARIES ${OPENGL_LIBRARIES})
+IF (APPLE)
+  FIND_PACKAGE(GLUT REQUIRED)
   INCLUDE_DIRECTORIES(${GLUT_INCLUDE_DIR})
-  INCLUDE_DIRECTORIES(${GLEW_INCLUDE_DIR})
-ENDIF(GLEW_FOUND)
-
+  SET(OPENGL_GLEW_LIBRARIES ${OPENGL_GLEW_LIBRARIES} ${GLUT_LIBRARIES})
+ENDIF()
+FIND_PACKAGE(GLEW REQUIRED)
+INCLUDE_DIRECTORIES(${GLEW_INCLUDE_DIR})
+SET(OPENGL_GLEW_LIBRARIES ${OPENGL_GLEW_LIBRARIES} ${GLEW_LIBRARIES})
+IF(NOT HUGIN_SHARED OR NOT WIN32)
+  ADD_DEFINITIONS(-DGLEW_STATIC)
+ENDIF()
+
+IF(NOT APPLE AND NOT WIN32)
+FIND_PACKAGE(X11 REQUIRED)
+ENDIF()
 ##
 ## Panotools
 ##
@@ -241,6 +258,39 @@
 ENDIF(PANO13_FOUND) 
 INCLUDE_DIRECTORIES(${PANO_INCLUDE_DIR})
 
+# Check CXX11 compiler
+SET(CMAKE_CXX_STANDARD 11)
+SET(CMAKE_CXX_STANDARD_REQUIRED ON)
+# necessary threads lib
+SET(THREADS_PREFER_PTHREAD_FLAG ON)
+FIND_PACKAGE(Threads REQUIRED)
+
+IF(WIN32)
+  # for Windows Vista support
+  ADD_DEFINITIONS(-DPSAPI_VERSION=1)
+ENDIF(WIN32)
+
+# check if we have C++17 <filesystem> header
+INCLUDE(CheckCXXSourceCompiles)
+check_cxx_source_compiles(
+  "
+    #include <filesystem>
+    #include <string>
+    
+    int main()
+    {
+      std::tr2::sys::path filepath;
+      filepath=std::tr2::sys::absolute(filepath);
+      std::string s=filepath.filename().string();
+      return 0;    
+    };
+  "
+  HAVE_STD_FILESYSTEM
+)
+
+IF(HAVE_STD_FILESYSTEM)
+# in this combination we don't need Boost anymore
+ELSE()
 ##
 ## Boost
 ##
@@ -248,7 +298,7 @@
 # Now it is a cache variable you can edit in cmakesetup --TKS
 #
 IF( NOT Boost_root_suffix )
-  SET( Boost_root_suffix _1_41_0 CACHE STRING "suffix of boost root dir." FORCE )
+  SET( Boost_root_suffix _1_54_0 CACHE STRING "suffix of boost root dir." FORCE )
 ENDIF( NOT Boost_root_suffix )
 
 IF(WIN32)
@@ -263,31 +313,99 @@
     SET(Boost_USE_STATIC_RUNTIME ON)
   ENDIF(${HUGIN_SHARED})
   # If BOOST_ROOT was defined in the environment, use it. 
-  if (NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "") 
-    set(BOOST_ROOT $ENV{BOOST_ROOT}) 
-  else(NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "") 
-    set(BOOST_ROOT ${SOURCE_BASE_DIR}/boost${Boost_root_suffix}) 
-   endif(NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "") 
+  IF(NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "") 
+    SET(BOOST_ROOT $ENV{BOOST_ROOT})
+  ENDIF()
+  IF(NOT BOOST_ROOT)
+    SET(BOOST_ROOT ${SOURCE_BASE_DIR}/boost${Boost_root_suffix})
+  ENDIF()
+  
+  FIND_PATH(ENBLEND_DIR bin/enblend.exe enblend.exe
+    PATHS 
+      ${SOURCE_BASE_DIR}/enblend-enfuse-4.2-win64 
+      ${SOURCE_BASE_DIR}/enblend-enfuse-4.2-win32 
+      ${SOURCE_BASE_DIR}/enblend-enfuse-4.1.5-win64 
+      ${SOURCE_BASE_DIR}/enblend-enfuse-4.1.5-win32 
+      ${SOURCE_BASE_DIR}/enblend-enfuse-4.1.4-win64 
+      ${SOURCE_BASE_DIR}/enblend-enfuse-4.1.4-win32 
+      ${SOURCE_BASE_DIR}/enblend-enfuse-4.1.3-win64 
+      ${SOURCE_BASE_DIR}/enblend-enfuse-4.1.3-win32 
+      ${SOURCE_BASE_DIR}/enblend-enfuse-4.1.2-win64 
+      ${SOURCE_BASE_DIR}/enblend-enfuse-4.1.2-win32 
+      ${SOURCE_BASE_DIR}/enblend-enfuse-4.1.1-win64 
+      ${SOURCE_BASE_DIR}/enblend-enfuse-4.1.1-win32 
+      ${SOURCE_BASE_DIR}/enblend-enfuse-4.1.1 
+      ${SOURCE_BASE_DIR}/enblend-enfuse-4.1 
+      ${SOURCE_BASE_DIR}/enblend-enfuse-4.0
+      ${SOURCE_BASE_DIR}/enblend-3.1
+      ${SOURCE_BASE_DIR}/enblend-enfuse-3.2
+      ${SOURCE_BASE_DIR}/enblend.build
+      ${SOURCE_BASE_DIR}/enblend
+    DOC "Location of enblend"
+    NO_DEFAULT_PATH
+  )
+  IF(NOT ENBLEND_DIR)
+    MESSAGE(FATAL_ERROR "enblend-enfuse files not found.")
+  ENDIF()
 ENDIF(WIN32)
-FIND_PACKAGE(Boost 1.41 COMPONENTS thread date_time regex filesystem iostreams system signals)
+
+FIND_PACKAGE(Boost 1.47 COMPONENTS filesystem system)
+
 IF (NOT Boost_FOUND)
   IF(WIN32)
     MESSAGE(FATAL_ERROR "Boost not found. Bad BOOST_ROOT? On windows, try editing Boost_root_suffix")
   ELSE()
-    MESSAGE(FATAL_ERROR "Boost not found. Maybe wrong version. Hugin requires at least version 1.41")
+    MESSAGE(FATAL_ERROR "Boost not found. Maybe wrong version. Hugin requires at least version 1.47")
   ENDIF()
 ENDIF (NOT Boost_FOUND)
 
 INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
 LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
-
-FIND_PACKAGE(Threads)
-FIND_PACKAGE(ZThread)
-FIND_PACKAGE(flann)
+ENDIF()
+
+# littleCMS 2 now
+FIND_PACKAGE(LCMS2 REQUIRED)
+INCLUDE_DIRECTORIES(${LCMS2_INCLUDE_DIR})
+IF(WIN32)
+  IF(${HUGIN_SHARED})
+    ADD_DEFINITIONS(-DCMS_DLL)
+  ENDIF()
+ENDIF()
+
+FIND_PACKAGE(FLANN)
 
 IF(NOT FLANN_FOUND)
   INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/foreign)
 ENDIF(NOT FLANN_FOUND)
+
+FIND_PACKAGE(FFTW)
+IF(FFTW_FOUND)
+  MESSAGE(STATUS "Found FFTW library. Activated support for FFT fast cross correlation used by fine-tune feature.")
+  INCLUDE_DIRECTORIES(${FFTW_INCLUDE_DIR})
+  SET(HAVE_FFTW TRUE)
+ELSE()
+  MESSAGE(STATUS "Not found FFTW library. Deactivating support for FFT fast cross correlation used by fine-tune feature.")
+ENDIF()
+
+# Check for OpenMP
+IF(APPLE)
+  #we need a special search routine for mac, see changes in file CMakeModules/FindOpenMPMac.cmake
+  FIND_PACKAGE(OpenMPMac)
+ELSE()
+  FIND_PACKAGE(OpenMP)
+ENDIF()
+IF(OPENMP_FOUND)
+  MESSAGE(STATUS "Compiler supports OpenMP. Activating support for it.")
+  ADD_COMPILE_OPTIONS(${OpenMP_CXX_FLAGS})
+  SET(HAVE_OPENMP TRUE)
+  IF(OpenMP_CXX_FLAGS AND NOT MSVC)
+    SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_CXX_FLAGS}")
+    SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${OpenMP_CXX_FLAGS}")
+    SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${OpenMP_CXX_FLAGS}")
+  ENDIF()
+ELSE()
+  MESSAGE(WARNING "Compiler does not support OpenMP. OpenMP is required for multi-threaded processes. So only single threaded execution is compiled now.") 
+ENDIF()
 
 IF(WIN32)
   # HTML Helpworkshop for creating help file
@@ -297,8 +415,8 @@
   ENDIF()
 ENDIF(WIN32)
 
-FIND_PACKAGE(Lensfun REQUIRED)
-INCLUDE_DIRECTORIES(${LENSFUN_INCLUDE_DIR})
+FIND_PACKAGE(SQLite3 REQUIRED)
+INCLUDE_DIRECTORIES(${SQLITE3_INCLUDE_DIR})
 
 IF(UNIX)
   OPTION(BUILD_HSI "Python Scripting Interface" ON)
@@ -404,7 +522,7 @@
   MESSAGE("Building in Debug mode, resulting programs will be SLOW")
   ADD_DEFINITIONS(-DDEBUG)
   IF(UNIX)
-    ADD_DEFINITIONS(-Wall)
+    ADD_COMPILE_OPTIONS(-Wall)
   ENDIF(UNIX)
 ENDIF(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
 
@@ -429,9 +547,12 @@
 SET(LIBDIR  lib${LIB_SUFFIX})
 SET(INSTALL_XRC_DIR ${CMAKE_INSTALL_PREFIX}/share/hugin/xrc)
 SET(INSTALL_DATA_DIR ${CMAKE_INSTALL_PREFIX}/share/hugin/data)
-
-# setup bundle install prefix
+SET(INSTALL_LOCALE_DIR ${CMAKE_INSTALL_PREFIX}/${LOCALEDIR})
+
 IF (APPLE)
+  SET(CMAKE_EXE_LINKER_FLAGS    "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++")
+  SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -stdlib=libc++ -lc++")
+  # setup bundle install prefix
   IF (NOT MAC_SELF_CONTAINED_BUNDLE)
     IF (CMAKE_INSTALL_PREFIX STREQUAL "/opt/local")
       # MacPorts
@@ -464,8 +585,8 @@
 ELSE (UNIX)
 
   IF (${HUGIN_SHARED})
-    ADD_DEFINITIONS(-DVIGRA_DLL)
     ADD_DEFINITIONS(-DOPENEXR_DLL)
+    ADD_DEFINITIONS(-DEXV_HAVE_DLL)
     ADD_DEFINITIONS(-DHugin_shared)
     ADD_DEFINITIONS(-DPANO13_DLL)
     SET(HUGIN_SHARED_LIBS 1)
@@ -529,31 +650,80 @@
         "${NEW_FLAGS} /NODEFAULTLIB:\"MSVCRT.lib\" /NODEFAULTLIB:\"MSVCRTd.lib\""
        CACHE STRING "for MSVC" FORCE
     )
+    FOREACH(CFG "MINSIZEREL" "RELEASE" "RELWITHDEBINFO")
+      SET(NEW_FLAGS "${CMAKE_EXE_LINKER_FLAGS_${CFG}}")
+      STRING(REPLACE " /LTCG" "" NEW_FLAGS "${NEW_FLAGS}")
+      SET(CMAKE_EXE_LINKER_FLAGS_${CFG} "${NEW_FLAGS} /LTCG" CACHE STRING "overwritten" FORCE)
+    ENDFOREACH()
+    SET(NEW_FLAGS "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO}")
+    STRING(REPLACE " /INCREMENTAL:NO" "" NEW_FLAGS "${NEW_FLAGS}")
+    STRING(REPLACE " /INCREMENTAL" "" NEW_FLAGS "${NEW_FLAGS}")
+    SET(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${NEW_FLAGS} /INCREMENTAL:NO" CACHE STRING "overwritten" FORCE)
     ENDIF(NOT ${HUGIN_SHARED})
   ENDIF(MSVC)
 ENDIF (UNIX)
 
-IF (APPLE)
-   #
-   if (${MAC_SELF_CONTAINED_BUNDLE})
-      MESSAGE("-- Configuring hugin for fully bundled version. (not yet working)")
-   endif(${MAC_SELF_CONTAINED_BUNDLE})
-   
-   #This namespace workaround is not needed for CMake >= 2.5.x
-   ## Add needed Compiler and Linker flags for OSX
-      IF (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
-      	 SET (CMAKE_C_FLAGS:STRING "\"$CMAKE_C_FLAGS\" -flat_namespace -undefined suppress" )
-	 SET (CMAKE_CXX_FLAGS:STRING "\"$CMAKE_CXX_FLAGS\" -flat_namespace -undefined suppress" )
-	 SET (CMAKE_LDFLAGS:STRING "\"$CMAKE_LD_FLAGS\"" )
-	 SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}  -flat_namespace -undefined suppress" )
-	 SET (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}  -flat_namespace -undefined suppress" )
-	 SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}  -flat_namespace -undefined suppress" )
-         SET (CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib" )
-	 IF (${CMAKE_BUILD_TYPE} STREQUAL "Release")
-		SET (CMAKE_C_FLAGS_RELEASE:STRING " $CMAKE_C_FLAGS_RELEASE ")
-		SET (CMAKE_CXX_FLAGS_RELEASE:STRING " $CMAKE_CXX_FLAGS_RELEASE ")
-	 ENDIF (${CMAKE_BUILD_TYPE} STREQUAL "Release")
-      ENDIF (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
+IF(APPLE)
+
+  IF(MAC_SELF_CONTAINED_BUNDLE)
+    SET(CMAKE_MACOSX_RPATH FALSE) 
+
+    CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/CMakeModules/PackageMacAppBundleLibs.sh.in
+             ${hugin_BINARY_DIR}/${BINDIR}/PackageMacAppBundleLibs.sh @ONLY IMMEDIATE)
+
+
+    ADD_CUSTOM_TARGET(Mac ALL)
+    SET(APPS Hugin PTBatcherGUI calibrate_lens_gui HuginStitchProject)
+    SET(APPS_DIR ${CMAKE_BINARY_DIR}/src/hugin1/hugin
+                 ${CMAKE_BINARY_DIR}/src/hugin1/ptbatcher
+                 ${CMAKE_BINARY_DIR}/src/hugin1/calibrate_lens
+                 ${CMAKE_BINARY_DIR}/src/hugin1/stitch_project )
+
+    foreach(_var RANGE 0 3)
+      LIST(GET APPS ${_var} _target)
+      LIST(GET APPS_DIR ${_var} _target_dir)
+      ADD_DEPENDENCIES(Mac ${_target})
+      ADD_CUSTOM_COMMAND(
+        TARGET Mac
+        COMMAND bash ${hugin_BINARY_DIR}/${BINDIR}/PackageMacAppBundleLibs.sh
+        ARGS ${_target} ${_target_dir}
+      )
+    ENDFOREACH(_var)
+
+    ADD_CUSTOM_COMMAND(
+      TARGET Mac
+      POST_BUILD
+      COMMAND ${CMAKE_SOURCE_DIR}/mac/PackageCreateToolsLibs.sh
+      ARGS ${CMAKE_CURRENT_BINARY_DIR}/tools_mac
+      fulla tca_correct vig_optimize hugin_lensdb hugin_executor pano_trafo pto_gen 
+        pto_lensstack pto_mask pto_merge pto_move pto_template pto_var deghosting_mask)
+
+    INSTALL( DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tools_mac
+             DESTINATION Hugin 
+             COMPONENT "tools_mac"
+             FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
+             PATTERN .DS_Store EXCLUDE )
+
+  ENDIF(MAC_SELF_CONTAINED_BUNDLE)
+
+  
+  ADD_DEFINITIONS(-D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=0)
+
+  #This namespace workaround is not needed for CMake >= 2.5.x
+  ## Add needed Compiler and Linker flags for OSX
+  IF (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
+      SET (CMAKE_C_FLAGS:STRING "\"$CMAKE_C_FLAGS\" -flat_namespace -undefined suppress" )
+      SET (CMAKE_CXX_FLAGS:STRING "\"$CMAKE_CXX_FLAGS\" -flat_namespace -undefined suppress" )
+      SET (CMAKE_LDFLAGS:STRING "\"$CMAKE_LD_FLAGS\"" )
+      SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}  -flat_namespace -undefined suppress" )
+      SET (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}  -flat_namespace -undefined suppress" )
+      SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}  -flat_namespace -undefined suppress" )
+      SET (CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib" )
+    IF (${CMAKE_BUILD_TYPE} STREQUAL "Release")
+      SET (CMAKE_C_FLAGS_RELEASE:STRING " $CMAKE_C_FLAGS_RELEASE ")
+      SET (CMAKE_CXX_FLAGS_RELEASE:STRING " $CMAKE_CXX_FLAGS_RELEASE ")
+    ENDIF (${CMAKE_BUILD_TYPE} STREQUAL "Release")
+  ENDIF (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
 ENDIF (APPLE)
 
 
@@ -575,11 +745,12 @@
   SET(CPACK_PACKAGE_VERSION_PATCH "${V_PATCH}.${CPACK_PACKAGE_VERSION_PATCH}.local")
 ENDIF()
 
-SET(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${V_MAJOR}.${V_MINOR}")
 SET(CPACK_SOURCE_PACKAGE_FILE_NAME "hugin-${V_MAJOR}.${V_MINOR}.${V_PATCH}")
-SET(CPACK_SOURCE_GENERATOR "TGZ;TBZ2")
+SET(CPACK_SOURCE_GENERATOR "TBZ2")
 SET(CPACK_PACKAGE_CONTACT "hugin-ptx@googlegroups.com")
-SET(CPACK_SET_DESTDIR "ON")
+IF(NOT WIN32)
+  SET(CPACK_SET_DESTDIR "ON")
+ENDIF()
 SET(CPACK_SOURCE_IGNORE_FILES
 "/_CPack_Packages/"
 "/CMakeCache.txt$"
@@ -682,9 +853,83 @@
   SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libpano13(>=2.9.17)")
 ENDIF()
 
+# ignore some directories when creating rpm
+SET(CPACK_RPM_SPEC_MORE_DEFINE "%define ignore \#")
+SET(CPACK_RPM_USER_FILELIST 
+  "%ignore /usr/local"
+  "%ignore /usr/local/bin" 
+  "%ignore /usr/local/lib" 
+  "%ignore /usr/local/share" 
+  "%ignore /usr/local/share/applications" 
+  "%ignore /usr/local/share/man" 
+  "%ignore /usr/local/share/man/man1"
+  "%ignore /usr/lib/python2.7"
+  "%ignore /usr/lib/python2.7/site-packages"
+)
+
 message(STATUS "Current source dir = ${CMAKE_CURRENT_SOURCE_DIR}")
 SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/Debian/postinst"
 				       "${CMAKE_CURRENT_SOURCE_DIR}/Debian/shlibs.local")
+
+
+IF(APPLE)
+  SET(CPACK_PACKAGE_NAME "Hugin")
+  SET(CPACK_GENERATOR "DragNDrop")
+  SET(CPACK_DMG_FORMAT "UDBZ")
+  SET(CPACK_COMPONENTS_ALL tools_mac Hugin PTBatcherGUI calibrate_lens_gui HuginStitchProject)
+  SET(CPACK_SYSTEM_NAME "Mac")
+  SET(CPACK_PACKAGE_FILE_NAME "Hugin-${V_MAJOR}.${V_MINOR}.${V_PATCH}")
+
+  #has to be 72dpi
+  SET(CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_SOURCE_DIR}/mac/DmgBackground.jpg")
+
+  # SET(CPACK_DMG_DS_STORE_SETUP_SCRIPT "${CMAKE_SOURCE_DIR}/mac/DmgScript.scpt")
+  SET(CPACK_DMG_DS_STORE "${CMAKE_SOURCE_DIR}/mac/DmgDS_Store.in")
+
+ENDIF(APPLE)
+
+IF(MSVC)
+# configure variables for wix toolset generator
+MATH(EXPR VERSION_WIN_MAJOR "${V_MAJOR}/100")
+MATH(EXPR VERSION_WIN_MINOR "${V_MAJOR}%100")
+SET(CPACK_PACKAGE_VERSION_MAJOR "${VERSION_WIN_MAJOR}")
+SET(CPACK_PACKAGE_VERSION_MINOR "${VERSION_WIN_MINOR}")
+SET(CPACK_PACKAGE_VERSION_PATCH "${V_MINOR}")
+SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING.txt")
+IF(CMAKE_CL_64)
+  SET(CPACK_WIX_UPGRADE_GUID "1B85EFEB-F843-49C6-80D3-A539B035D319")
+ELSE()
+  SET(CPACK_WIX_UPGRADE_GUID "F33AD91A-C09A-4C6E-A027-D56611228094")
+ENDIF()
+# installing to start menu requires at least CMake 3.3
+cmake_minimum_required(VERSION 3.3.0 FATAL_ERROR )
+SET(CPACK_WIX_PROGRAM_MENU_FOLDER Hugin)
+SET(CPACK_WIX_UI_DIALOG "${CMAKE_SOURCE_DIR}/platforms/windows/wix/big_banner.bmp")
+SET(CPACK_WIX_UI_BANNER "${CMAKE_SOURCE_DIR}/platforms/windows/wix/top_banner.bmp")
+SET(CPACK_WIX_PRODUCT_ICON "${CMAKE_SOURCE_DIR}/src/hugin1/hugin/xrc/data/hugin.ico")
+SET(CPACK_PACKAGE_INSTALL_DIRECTORY "Hugin")
+SET(CPACK_PACKAGE_NAME "Hugin")
+SET(CPACK_PACKAGE_VENDOR "Hugin developer team")
+SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Hugin - Panorama photo stitcher")
+IF(MSVC14)
+  IF(CMAKE_CL_64)
+    SET(CPACK_WIX_EXTRA_SOURCES 
+      "${CMAKE_SOURCE_DIR}/platforms/windows/wix/redist_vc14_x64.wxs"
+      "${CMAKE_SOURCE_DIR}/platforms/windows/wix/filetype.wxs"
+    )
+  ELSE()
+    SET(CPACK_WIX_EXTRA_SOURCES
+      "${CMAKE_SOURCE_DIR}/platforms/windows/wix/redist_vc14_x86.wxs"
+      "${CMAKE_SOURCE_DIR}/platforms/windows/wix/filetype.wxs"
+    )
+  ENDIF()
+  SET(CPACK_WIX_PATCH_FILE "${CMAKE_SOURCE_DIR}/platforms/windows/wix/redist.xml")
+ELSE()
+  SET(CPACK_WIX_EXTRA_SOURCES "${CMAKE_SOURCE_DIR}/platforms/windows/wix/filetype.wxs")
+  SET(CPACK_WIX_PATCH_FILE "${CMAKE_SOURCE_DIR}/platforms/windows/wix/filetype.xml")
+ENDIF()
+ENDIF()
+				       
 INCLUDE(CPack)
 
 ##

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks