CMake file cleanup

This commit is contained in:
Morgan Hardwood 2018-12-02 23:00:29 +01:00
parent 39fa791384
commit 4e79d68807
4 changed files with 57 additions and 57 deletions

View File

@ -1,11 +1,11 @@
if(APPLE) if(APPLE)
cmake_minimum_required(VERSION 3.3) cmake_minimum_required(VERSION 3.3)
CMAKE_POLICY(SET CMP0025 NEW) cmake_policy(SET CMP0025 NEW)
else() else()
cmake_minimum_required(VERSION 2.8.8) cmake_minimum_required(VERSION 2.8.8)
endif() endif()
# Must stay before the PROJECT() command: # Must stay before the project() command:
if(${CMAKE_EXTRA_GENERATOR} MATCHES "Eclipse CDT4") if(${CMAKE_EXTRA_GENERATOR} MATCHES "Eclipse CDT4")
set(CMAKE_CXX_COMPILER_ARG1 "-std=c++11" CACHE STRING "C++ version for eclipse" FORCE) 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 # Users building with Eclipse should set CMAKE_ECLIPSE_VERSION through the
@ -13,18 +13,18 @@ if(${CMAKE_EXTRA_GENERATOR} MATCHES "Eclipse CDT4")
#set(CMAKE_ECLIPSE_VERSION "4.6.0" CACHE STRING "Eclipse version" FORCE) #set(CMAKE_ECLIPSE_VERSION "4.6.0" CACHE STRING "Eclipse version" FORCE)
endif() endif()
PROJECT(RawTherapee) project(RawTherapee)
# The default target is Debug: # The default target is Debug:
if(CMAKE_BUILD_TYPE STREQUAL "") if(CMAKE_BUILD_TYPE STREQUAL "")
set (CMAKE_BUILD_TYPE Debug CACHE STRING "One of: None Debug Release RelWithDebInfo MinSizeRel" FORCE) set(CMAKE_BUILD_TYPE Debug CACHE STRING "One of: None Debug Release RelWithDebInfo MinSizeRel" FORCE)
endif() 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 required C and C++ standards and check GCC version:
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 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") 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!") message(FATAL_ERROR "Building RawTherapee requires using GCC version 4.9 or higher!")
@ -32,14 +32,14 @@ endif()
# We might want to build using the old C++ ABI, even when using a new GCC version: # We might want to build using the old C++ ABI, even when using a new GCC version:
if(USE_OLD_CXX_ABI) if(USE_OLD_CXX_ABI)
add_definitions (-D_GLIBCXX_USE_CXX11_ABI=0) add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
endif() endif()
if(UPPER_CMAKE_BUILD_TYPE STREQUAL "DEBUG") if(UPPER_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
add_definitions (-D_DEBUG) add_definitions(-D_DEBUG)
else() else()
add_definitions (-DNDEBUG) add_definitions(-DNDEBUG)
add_definitions (-D_DNDEBUG) add_definitions(-D_DNDEBUG)
endif() endif()
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
@ -141,7 +141,7 @@ if(WIN32 OR APPLE)
if(BUILD_BUNDLE) 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.") message(STATUS "You have set BUILD_BUNDLE=ON but this is not necessary - the option is forced to ON for Windows and macOS.")
endif() endif()
set (BUILD_BUNDLE ON FORCE) set(BUILD_BUNDLE ON FORCE)
endif() endif()
if(NOT DEFINED BUNDLE_BASE_INSTALL_DIR) if(NOT DEFINED BUNDLE_BASE_INSTALL_DIR)
@ -262,7 +262,7 @@ endif()
if(NOT BUILD_BUNDLE) if(NOT BUILD_BUNDLE)
foreach(path BINDIR DATADIR LIBDIR DOCDIR CREDITSDIR LICENCEDIR) foreach(path BINDIR DATADIR LIBDIR DOCDIR CREDITSDIR LICENCEDIR)
if(NOT (IS_ABSOLUTE "${${path}}")) if(NOT (IS_ABSOLUTE "${${path}}"))
message (FATAL_ERROR "The ${path} path has to be absolute when using -DBUILD_BUNDLE=OFF") message(FATAL_ERROR "The ${path} path has to be absolute when using -DBUILD_BUNDLE=OFF")
endif() endif()
endforeach() endforeach()
endif() endif()
@ -342,35 +342,35 @@ endif()
if(WITH_LTO) if(WITH_LTO)
# Using LTO with older versions of binutils requires setting extra flags # Using LTO with older versions of binutils requires setting extra flags
SET(BINUTILS_VERSION_MININUM "2.29") set(BINUTILS_VERSION_MININUM "2.29")
execute_process(COMMAND ar --version OUTPUT_VARIABLE BINUTILS_VERSION_DETECTED) execute_process(COMMAND ar --version OUTPUT_VARIABLE BINUTILS_VERSION_DETECTED)
string(REGEX REPLACE ".* ([0-9.]+)\n.*" "\\1" BINUTILS_VERSION_DETECTED "${BINUTILS_VERSION_DETECTED}") string(REGEX REPLACE ".* ([0-9.]+)\n.*" "\\1" BINUTILS_VERSION_DETECTED "${BINUTILS_VERSION_DETECTED}")
if("${BINUTILS_VERSION_DETECTED}" VERSION_LESS "${BINUTILS_VERSION_MININUM}") if("${BINUTILS_VERSION_DETECTED}" VERSION_LESS "${BINUTILS_VERSION_MININUM}")
if(APPLE) if(APPLE)
SET(CMAKE_AR "/opt/local/bin/ar") set(CMAKE_AR "/opt/local/bin/ar")
SET(CMAKE_RANLIB "/opt/local/bin/ranlib") set(CMAKE_RANLIB "/opt/local/bin/ranlib")
else() else()
SET(CMAKE_AR "/usr/bin/gcc-ar") set(CMAKE_AR "/usr/bin/gcc-ar")
SET(CMAKE_RANLIB "/usr/bin/gcc-ranlib") set(CMAKE_RANLIB "/usr/bin/gcc-ranlib")
endif() endif()
message(STATUS "Binutils version detected as less than " ${BINUTILS_VERSION_MININUM} " - setting CMake parameters to enable LTO linking:\n CMAKE_AR=\"" ${CMAKE_AR} "\"\n CMAKE_RANLIB=\"" ${CMAKE_RANLIB} "\"") message(STATUS "Binutils version detected as less than " ${BINUTILS_VERSION_MININUM} " - setting CMake parameters to enable LTO linking:\n CMAKE_AR=\"" ${CMAKE_AR} "\"\n CMAKE_RANLIB=\"" ${CMAKE_RANLIB} "\"")
endif() endif()
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -flto") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -flto")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto")
endif() endif()
if(WITH_SAN) if(WITH_SAN)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=${WITH_SAN}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=${WITH_SAN}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_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}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=${WITH_SAN}")
endif() endif()
if(WITH_PROF) if(WITH_PROF)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg")
endif() endif()
if(OPTION_OMP) if(OPTION_OMP)

View File

@ -2,25 +2,25 @@
# If we find ReleaseInfo.cmake we use the info from there and don't need Git to be installed # If we find ReleaseInfo.cmake we use the info from there and don't need Git to be installed
find_file(REL_INFO_FILE ReleaseInfo.cmake PATHS "${PROJECT_SOURCE_DIR}" NO_DEFAULT_PATH) find_file(REL_INFO_FILE ReleaseInfo.cmake PATHS "${PROJECT_SOURCE_DIR}" NO_DEFAULT_PATH)
if (REL_INFO_FILE STREQUAL REL_INFO_FILE-NOTFOUND) if(REL_INFO_FILE STREQUAL REL_INFO_FILE-NOTFOUND)
# we look for the git command in this paths by order of preference # we look for the git command in this paths by order of preference
if (WIN32) if(WIN32)
find_program(GIT_CMD git.exe HINTS ENV Path PATH_SUFFIXES ../) find_program(GIT_CMD git.exe HINTS ENV Path PATH_SUFFIXES ../)
elseif (APPLE) elseif(APPLE)
find_program(GIT_CMD git PATHS "/opt/local/bin" "/usr/local/bin" "/usr/bin") find_program(GIT_CMD git PATHS "/opt/local/bin" "/usr/local/bin" "/usr/bin")
find_program(GIT_CMD git) find_program(GIT_CMD git)
set (SHELL "/bin/bash") set(SHELL "/bin/bash")
else (WIN32) # Linux else(WIN32) # Linux
find_program(GIT_CMD git) find_program(GIT_CMD git)
set (SHELL "/bin/bash") set(SHELL "/bin/bash")
endif (WIN32) endif(WIN32)
# Fail if Git is not installed # Fail if Git is not installed
if (GIT_CMD STREQUAL GIT_CMD-NOTFOUND) if(GIT_CMD STREQUAL GIT_CMD-NOTFOUND)
message(FATAL_ERROR "git command not found!") message(FATAL_ERROR "git command not found!")
else () else()
message(STATUS "git command found: ${GIT_CMD}") message(STATUS "git command found: ${GIT_CMD}")
endif () endif()
# Get version description. # Get version description.
# Depending on whether you checked out a branch (dev) or a tag (release), # Depending on whether you checked out a branch (dev) or a tag (release),
@ -50,19 +50,19 @@ if (REL_INFO_FILE STREQUAL REL_INFO_FILE-NOTFOUND)
execute_process(COMMAND ${GIT_CMD} rev-list --count HEAD --not --tags OUTPUT_VARIABLE GIT_COMMITS_SINCE_BRANCH OUTPUT_STRIP_TRAILING_WHITESPACE WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}") execute_process(COMMAND ${GIT_CMD} rev-list --count HEAD --not --tags OUTPUT_VARIABLE GIT_COMMITS_SINCE_BRANCH OUTPUT_STRIP_TRAILING_WHITESPACE WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}")
# If user checked-out something which is not a branch, use the description as branch name. # If user checked-out something which is not a branch, use the description as branch name.
if (GIT_BRANCH STREQUAL "") if(GIT_BRANCH STREQUAL "")
set (GIT_BRANCH "${GIT_DESCRIBE}") set(GIT_BRANCH "${GIT_DESCRIBE}")
endif() endif()
# Create numeric version. # Create numeric version.
# This version is nonsense, either don't use it at all or use it only where you have no other choice, e.g. Inno Setup's VersionInfoVersion. # This version is nonsense, either don't use it at all or use it only where you have no other choice, e.g. Inno Setup's VersionInfoVersion.
# Strip everything after hyphen, e.g. "5.0-gtk2" -> "5.0", "5.1-rc1" -> "5.1" (ergo BS). # Strip everything after hyphen, e.g. "5.0-gtk2" -> "5.0", "5.1-rc1" -> "5.1" (ergo BS).
if (GIT_COMMITS_SINCE_TAG STREQUAL "") if(GIT_COMMITS_SINCE_TAG STREQUAL "")
set (GIT_NUMERIC_VERSION_BS "0.0.0") set(GIT_NUMERIC_VERSION_BS "0.0.0")
else () else()
string(REGEX REPLACE "-.*" "" GIT_NUMERIC_VERSION_BS ${GIT_DESCRIBE}) string(REGEX REPLACE "-.*" "" GIT_NUMERIC_VERSION_BS ${GIT_DESCRIBE})
set(GIT_NUMERIC_VERSION_BS "${GIT_NUMERIC_VERSION_BS}.${GIT_COMMITS_SINCE_TAG}") set(GIT_NUMERIC_VERSION_BS "${GIT_NUMERIC_VERSION_BS}.${GIT_COMMITS_SINCE_TAG}")
endif () endif()
message(STATUS "Git checkout information:") message(STATUS "Git checkout information:")
message(STATUS " Commit description: ${GIT_DESCRIBE}") message(STATUS " Commit description: ${GIT_DESCRIBE}")
@ -73,38 +73,38 @@ if (REL_INFO_FILE STREQUAL REL_INFO_FILE-NOTFOUND)
message(STATUS " Commits since branch: ${GIT_COMMITS_SINCE_BRANCH}") message(STATUS " Commits since branch: ${GIT_COMMITS_SINCE_BRANCH}")
message(STATUS " Version (unreliable): ${GIT_NUMERIC_VERSION_BS}") message(STATUS " Version (unreliable): ${GIT_NUMERIC_VERSION_BS}")
if (NOT DEFINED CACHE_NAME_SUFFIX) if(NOT DEFINED CACHE_NAME_SUFFIX)
set(CACHE_NAME_SUFFIX "${GIT_DESCRIBE}") set(CACHE_NAME_SUFFIX "${GIT_DESCRIBE}")
message(STATUS "CACHE_NAME_SUFFIX was not defined, it is now \"${CACHE_NAME_SUFFIX}\"") message(STATUS "CACHE_NAME_SUFFIX was not defined, it is now \"${CACHE_NAME_SUFFIX}\"")
else () else()
message(STATUS "CACHE_NAME_SUFFIX is \"${CACHE_NAME_SUFFIX}\"") message(STATUS "CACHE_NAME_SUFFIX is \"${CACHE_NAME_SUFFIX}\"")
endif () endif()
else (REL_INFO_FILE STREQUAL REL_INFO_FILE-NOTFOUND) else(REL_INFO_FILE STREQUAL REL_INFO_FILE-NOTFOUND)
include("${PROJECT_SOURCE_DIR}/ReleaseInfo.cmake") include("${PROJECT_SOURCE_DIR}/ReleaseInfo.cmake")
endif (REL_INFO_FILE STREQUAL REL_INFO_FILE-NOTFOUND) endif(REL_INFO_FILE STREQUAL REL_INFO_FILE-NOTFOUND)
if (WIN32) if(WIN32)
if (BIT_DEPTH EQUAL 4) if(BIT_DEPTH EQUAL 4)
set(BUILD_BIT_DEPTH 32) set(BUILD_BIT_DEPTH 32)
# 32 bits builds has to be installable on 64 bits system, to support WinXP/64. # 32 bits builds has to be installable on 64 bits system, to support WinXP/64.
set(ARCHITECTURE_ALLOWED "x86 x64 ia64") set(ARCHITECTURE_ALLOWED "x86 x64 ia64")
# installing in 32 bits mode even on 64 bits OS and architecture # installing in 32 bits mode even on 64 bits OS and architecture
set(INSTALL_MODE "") set(INSTALL_MODE "")
elseif (BIT_DEPTH EQUAL 8) elseif(BIT_DEPTH EQUAL 8)
set(BUILD_BIT_DEPTH 64) set(BUILD_BIT_DEPTH 64)
# Restricting the 64 bits builds to 64 bits systems only # Restricting the 64 bits builds to 64 bits systems only
set(ARCHITECTURE_ALLOWED "x64 ia64") set(ARCHITECTURE_ALLOWED "x64 ia64")
# installing in 64 bits mode for all 64 bits processors, even for itanium architecture # installing in 64 bits mode for all 64 bits processors, even for itanium architecture
set(INSTALL_MODE "x64 ia64") set(INSTALL_MODE "x64 ia64")
endif (BIT_DEPTH EQUAL 4) endif(BIT_DEPTH EQUAL 4)
# set part of the output archive name # set part of the output archive name
set(SYSTEM_NAME "WinVista") set(SYSTEM_NAME "WinVista")
configure_file ("${PROJECT_SOURCE_DIR}/tools/win/InnoSetup/WindowsInnoSetup.iss.in" "${CMAKE_BINARY_DIR}/rtdata/WindowsInnoSetup.iss") configure_file("${PROJECT_SOURCE_DIR}/tools/win/InnoSetup/WindowsInnoSetup.iss.in" "${CMAKE_BINARY_DIR}/rtdata/WindowsInnoSetup.iss")
endif (WIN32) endif(WIN32)
# build version.h from template # build version.h from template
configure_file ("${PROJECT_SOURCE_DIR}/rtgui/version.h.in" "${CMAKE_BINARY_DIR}/rtgui/version.h") configure_file("${PROJECT_SOURCE_DIR}/rtgui/version.h.in" "${CMAKE_BINARY_DIR}/rtgui/version.h")
# build AboutThisBuild.txt from template # build AboutThisBuild.txt from template
configure_file ("${PROJECT_SOURCE_DIR}/AboutThisBuild.txt.in" "${CMAKE_BINARY_DIR}/AboutThisBuild.txt") configure_file("${PROJECT_SOURCE_DIR}/AboutThisBuild.txt.in" "${CMAKE_BINARY_DIR}/AboutThisBuild.txt")

View File

@ -164,7 +164,7 @@ add_dependencies(rtengine UpdateInfo)
# It may be nice to store library version too # It may be nice to store library version too
if(BUILD_SHARED_LIBS) if(BUILD_SHARED_LIBS)
install (TARGETS rtengine DESTINATION ${LIBDIR}) install(TARGETS rtengine DESTINATION ${LIBDIR})
endif() endif()
set_target_properties(rtengine PROPERTIES COMPILE_FLAGS "${RTENGINE_CXX_FLAGS}") set_target_properties(rtengine PROPERTIES COMPILE_FLAGS "${RTENGINE_CXX_FLAGS}")

View File

@ -24,7 +24,7 @@ set(PROC_TARGET_NUMBER 0 CACHE STRING "Target Processor")
# If you want to force the target processor name when PROC_TARGET_NUMBER = 0 or 2, # If you want to force the target processor name when PROC_TARGET_NUMBER = 0 or 2,
# uncomment the next line and replace labelWithoutQuotes by its value # uncomment the next line and replace labelWithoutQuotes by its value
#set (PROC_LABEL labelWithoutQuotes CACHE STRING "Target Processor label") #set(PROC_LABEL labelWithoutQuotes CACHE STRING "Target Processor label")
# Important: MinGW-w64 user may need to specify the -m32 or -m64 flag in CMAKE_CXX_FLAGS, # Important: MinGW-w64 user may need to specify the -m32 or -m64 flag in CMAKE_CXX_FLAGS,
# CMAKE_C_FLAGS and CMAKE_EXE_LINKER_FLAGS to select between 32/64bit build # CMAKE_C_FLAGS and CMAKE_EXE_LINKER_FLAGS to select between 32/64bit build