Rearrange the way mercurial-less build works (see issue 1342):

The cmake option AUTOMATED_BUILD_SYSTEM is removed and replaced by an automated
detection. Now it is possible to ship source tarballs that build without
mercurial on all platforms. The needed information is generated by the script
tools/generateReleaseInfo.{sh,bat} before the tarball is build.
This commit is contained in:
Philip Rinn
2012-06-18 17:35:53 +02:00
parent cbe233c8cf
commit 63cae64611
4 changed files with 99 additions and 123 deletions

View File

@@ -1,34 +1,39 @@
# cmakefile executed within a makefile target # cmakefile executed within a makefile target
# there should be a better way of getting the compiler + compiler version, not restrained to Gcc
execute_process(COMMAND gcc -dumpversion OUTPUT_VARIABLE GCC_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
# we look for the hg command in this paths by order of preference # If we find ReleaseInfo.cmake we use the info from there and don't need Mercurial to be installed
if (WIN32) find_file(REL_INFO_FILE ReleaseInfo.cmake PATHS "${CMAKE_CURRENT_SOURCE_DIR}" NO_DEFAULT_PATH)
if (REL_INFO_FILE STREQUAL REL_INFO_FILE-NOTFOUND)
# we look for the hg command in this paths by order of preference
if (WIN32)
find_file(HG_CMD hg.exe HINTS ENV Path PATH_SUFFIXES ../) find_file(HG_CMD hg.exe HINTS ENV Path PATH_SUFFIXES ../)
elseif (APPLE) elseif (APPLE)
find_file(HG_CMD hg PATHS "/opt/local/bin" "/usr/local/bin" "/usr/bin") find_file(HG_CMD hg PATHS "/opt/local/bin" "/usr/local/bin" "/usr/bin")
find_file(HG_CMD hg) find_file(HG_CMD hg)
set (SHELL "/bin/bash") set (SHELL "/bin/bash")
else (WIN32) # Linux else (WIN32) # Linux
find_file(HG_CMD hg) find_file(HG_CMD hg)
set (SHELL "/bin/bash") set (SHELL "/bin/bash")
endif (WIN32) endif (WIN32)
# the hg command is looked for again, at build time # Fail if Mercurial is not installed
if (HG_CMD STREQUAL HG_CMD-NOTFOUND) if (HG_CMD STREQUAL HG_CMD-NOTFOUND)
message(FATAL_ERROR "hg command not found!") message(FATAL_ERROR "hg command not found!")
else (HG_CMD STREQUAL HG_CMD-NOTFOUND) else (HG_CMD STREQUAL HG_CMD-NOTFOUND)
message(STATUS "hg command found: ${HG_CMD}") message(STATUS "hg command found: ${HG_CMD}")
endif (HG_CMD STREQUAL HG_CMD-NOTFOUND) endif (HG_CMD STREQUAL HG_CMD-NOTFOUND)
set (OUT_FILE "${SRC_DIR}/AboutThisBuild.txt") execute_process(COMMAND ${HG_CMD} -R ${CMAKE_CURRENT_SOURCE_DIR} branch OUTPUT_VARIABLE HG_BRANCH OUTPUT_STRIP_TRAILING_WHITESPACE)
# there should be a better way of getting the compiler + compiler version, not restrained to Gcc execute_process(COMMAND ${HG_CMD} parents --template={latesttag}.{latesttagdistance} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE HG_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND gcc -dumpversion OUTPUT_VARIABLE GCC_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process(COMMAND ${HG_CMD} parents --template={node|short} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE HG_CHANGESET OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${HG_CMD} -R ${SRC_DIR} branch OUTPUT_VARIABLE HG_BRANCH OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process(COMMAND ${HG_CMD} parents --template={latesttagdistance} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE HG_TAGDISTANCE OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${HG_CMD} parents --template={latesttag}.{latesttagdistance} WORKING_DIRECTORY ${SRC_DIR} OUTPUT_VARIABLE HG_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) if (CACHE_NAME_SUFFIX STREQUAL "")
execute_process(COMMAND ${HG_CMD} parents --template={node|short} WORKING_DIRECTORY ${SRC_DIR} OUTPUT_VARIABLE HG_CHANGESET OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process(COMMAND ${HG_CMD} parents --template={latesttag} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE CACHE_NAME_SUFFIX OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${HG_CMD} parents --template={latesttagdistance} WORKING_DIRECTORY ${SRC_DIR} OUTPUT_VARIABLE HG_TAGDISTANCE OUTPUT_STRIP_TRAILING_WHITESPACE) endif (CACHE_NAME_SUFFIX STREQUAL "")
if (CACHE_NAME_SUFFIX STREQUAL "") else (REL_INFO_FILE STREQUAL REL_INFO_FILE-NOTFOUND)
execute_process(COMMAND ${HG_CMD} parents --template={latesttag} WORKING_DIRECTORY ${SRC_DIR} OUTPUT_VARIABLE CACHE_NAME_SUFFIX OUTPUT_STRIP_TRAILING_WHITESPACE) include(${CMAKE_CURRENT_SOURCE_DIR}/ReleaseInfo.cmake)
endif () endif (REL_INFO_FILE STREQUAL REL_INFO_FILE-NOTFOUND)
# build version.h from template # build version.h from template
configure_file (${SRC_DIR}/rtgui/version.h.in ${SRC_DIR}/rtgui/version.h) configure_file (${SRC_DIR}/rtgui/version.h.in ${SRC_DIR}/rtgui/version.h)

View File

@@ -66,8 +66,6 @@ endif (APPLE)
option(USE_CLANG "Build rawtherapee with clang" OFF) option(USE_CLANG "Build rawtherapee with clang" OFF)
option(USE_EXPERIMENTAL_LANG_VERSIONS "Build RT with -std=c++0x" OFF) option(USE_EXPERIMENTAL_LANG_VERSIONS "Build RT with -std=c++0x" OFF)
option (AUTOMATED_BUILD_SYSTEM "TRUE if built by an automate" OFF)
option (BUILD_SHARED "Build rawtherapee with shared libraries" OFF) option (BUILD_SHARED "Build rawtherapee with shared libraries" 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)
@@ -190,105 +188,50 @@ find_package (PNG REQUIRED)
find_package (TIFF REQUIRED) find_package (TIFF REQUIRED)
find_package (ZLIB REQUIRED) find_package (ZLIB REQUIRED)
if (AUTOMATED_BUILD_SYSTEM) ## BEGIN: Generating AboutThisBuild.txt
# set the bit number information of the platform
message(WARNING "Automated build system mode! You have to make sure that AboutThisBuild.txt and rtgui/version.h are up-to-date by building RT at least one time with AUTOMATED_BUILD_SYSTEM=OFF.") if (CMAKE_SIZEOF_VOID_P EQUAL 4)
# Checking for the presence of AboutThisBuild.txt
find_file(ABOUT_FILE AboutThisBuild.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}" NO_DEFAULT_PATH)
if (ABOUT_FILE STREQUAL ABOUT_FILE-NOTFOUND)
message(FATAL_ERROR "AboutThisBuild.txt not found! You have to build RT at least one time with AUTOMATED_BUILD_SYSTEM=OFF to generate this file.")
endif (ABOUT_FILE STREQUAL ABOUT_FILE-NOTFOUND)
# Checking for the presence of version.h
find_file(VERSION_FILE version.h PATHS "${CMAKE_CURRENT_SOURCE_DIR}/rtgui" NO_DEFAULT_PATH)
if (VERSION_FILE STREQUAL VERSION_FILE-NOTFOUND)
message(FATAL_ERROR "rtgui/version.h not found! You have to build RT at least one time with AUTOMATED_BUILD_SYSTEM=OFF to generate this file.")
endif (VERSION_FILE STREQUAL VERSION_FILE-NOTFOUND)
else (AUTOMATED_BUILD_SYSTEM)
# set the bit number information of the platform
if (CMAKE_SIZEOF_VOID_P EQUAL 4)
set(PROC_BIT_DEPTH 32 bits) set(PROC_BIT_DEPTH 32 bits)
elseif (CMAKE_SIZEOF_VOID_P EQUAL 8) elseif (CMAKE_SIZEOF_VOID_P EQUAL 8)
set(PROC_BIT_DEPTH 64 bits) set(PROC_BIT_DEPTH 64 bits)
endif (CMAKE_SIZEOF_VOID_P EQUAL 4) endif (CMAKE_SIZEOF_VOID_P EQUAL 4)
#generating AboutThisBuild.txt # Get c++ and linker flags
if (WIN32) set(CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${UPPER_CMAKE_BUILD_TYPE}}")
set(LFLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_${UPPER_CMAKE_BUILD_TYPE}}")
add_custom_target (AboutFile ALL set(ABOUT_COMMAND_WITH_ARGS ${CMAKE_COMMAND}
COMMAND ${CMAKE_COMMAND}
-DSRC_DIR:STRING=${CMAKE_CURRENT_SOURCE_DIR} -DSRC_DIR:STRING=${CMAKE_CURRENT_SOURCE_DIR}
-DCACHE_NAME_SUFFIX:STRING=${CACHE_NAME_SUFFIX} -DCACHE_NAME_SUFFIX:STRING=${CACHE_NAME_SUFFIX}
-DSYSTEM:STRING=Windows
-DPROC_LABEL:STRING=\"${PROC_LABEL}\" -DPROC_LABEL:STRING=\"${PROC_LABEL}\"
-DPROC_BIT_DEPTH:STRING=\"${PROC_BIT_DEPTH}\" -DPROC_BIT_DEPTH:STRING=\"${PROC_BIT_DEPTH}\"
-DBUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DBUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DGTKMM_VERSION:STRING=${GTKMM_VERSION} -DGTKMM_VERSION:STRING=${GTKMM_VERSION}
-DCXX_FLAGS:STRING=\"${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${UPPER_CMAKE_BUILD_TYPE}}\"
-DLFLAGS:STRING=\"${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_${UPPER_CMAKE_BUILD_TYPE}}\"
-DOPTION_OMP:STRING=${OPTION_OMP} -DOPTION_OMP:STRING=${OPTION_OMP}
-DWITH_MYFILE_MMAP:STRING=${WITH_MYFILE_MMAP} -DWITH_MYFILE_MMAP:STRING=${WITH_MYFILE_MMAP})
-P ${CMAKE_CURRENT_SOURCE_DIR}/AboutThisBuild.cmake
COMMENT "Creating the about file"
)
find_file(HG_CMD hg.exe HINTS ENV Path PATH_SUFFIXES ../)
elseif (APPLE) if (WIN32)
list(APPEND ABOUT_COMMAND_WITH_ARGS -DSYSTEM:STRING=Windows
-DCXX_FLAGS:STRING=\"${CXX_FLAGS}\"
-DLFLAGS:STRING=\"${LFLAGS}\")
elseif (APPLE)
list(APPEND ABOUT_COMMAND_WITH_ARGS -DSYSTEM:STRING=Apple
-DCXX_FLAGS:STRING=${CXX_FLAGS}
-DLFLAGS:STRING=${LFLAGS})
else (WIN32)
list(APPEND ABOUT_COMMAND_WITH_ARGS -DSYSTEM:STRING=Linux
-DCXX_FLAGS:STRING=${CXX_FLAGS}
-DLFLAGS:STRING=${LFLAGS})
endif (WIN32)
add_custom_target (AboutFile ALL list(APPEND ABOUT_COMMAND_WITH_ARGS -P ${CMAKE_CURRENT_SOURCE_DIR}/AboutThisBuild.cmake)
COMMAND ${CMAKE_COMMAND}
-DSRC_DIR:STRING=${CMAKE_CURRENT_SOURCE_DIR}
-DCACHE_NAME_SUFFIX:STRING=${CACHE_NAME_SUFFIX}
-DSYSTEM:STRING=Apple
-DPROC_LABEL:STRING=\"${PROC_LABEL}\"
-DPROC_BIT_DEPTH:STRING=\"${PROC_BIT_DEPTH}\"
-DBUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DGTKMM_VERSION:STRING=${GTKMM_VERSION}
-DCXX_FLAGS:STRING=${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${UPPER_CMAKE_BUILD_TYPE}}
-DLFLAGS:STRING=${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_${UPPER_CMAKE_BUILD_TYPE}}
-DOPTION_OMP:STRING=${OPTION_OMP}
-DWITH_MYFILE_MMAP:STRING=${WITH_MYFILE_MMAP}
-P ${CMAKE_CURRENT_SOURCE_DIR}/AboutThisBuild.cmake
COMMENT "Creating the about file"
)
find_file(HG_CMD hg PATHS "/opt/local/bin" "/usr/local/bin" "/usr/bin")
find_file(HG_CMD hg)
else (WIN32) add_custom_target(AboutFile ALL
COMMAND ${ABOUT_COMMAND_WITH_ARGS}
add_custom_target (AboutFile ALL COMMENT "Creating the about file")
COMMAND ${CMAKE_COMMAND}
-DSRC_DIR:STRING=${CMAKE_CURRENT_SOURCE_DIR}
-DCACHE_NAME_SUFFIX:STRING=${CACHE_NAME_SUFFIX}
-DSYSTEM:STRING=Linux
-DPROC_LABEL:STRING=\"${PROC_LABEL}\"
-DPROC_BIT_DEPTH:STRING=\"${PROC_BIT_DEPTH}\"
-DBUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DGTKMM_VERSION:STRING=${GTKMM_VERSION}
-DCXX_FLAGS:STRING=${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${UPPER_CMAKE_BUILD_TYPE}}
-DLFLAGS:STRING=${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_${UPPER_CMAKE_BUILD_TYPE}}
-DOPTION_OMP:STRING=${OPTION_OMP}
-DWITH_MYFILE_MMAP:STRING=${WITH_MYFILE_MMAP}
-P ${CMAKE_CURRENT_SOURCE_DIR}/AboutThisBuild.cmake
COMMENT "Creating the about file"
)
find_file(HG_CMD hg)
endif (WIN32)
add_dependencies(AboutFile Debug Release MinSizeRel RelWithDebInfo)
if (HG_CMD STREQUAL HG_CMD-NOTFOUND)
message(FATAL_ERROR "hg command not found!")
else (HG_CMD STREQUAL HG_CMD-NOTFOUND)
message(STATUS "hg command found: ${HG_CMD}")
endif (HG_CMD STREQUAL HG_CMD-NOTFOUND)
endif (AUTOMATED_BUILD_SYSTEM)
add_dependencies(AboutFile Debug Release MinSizeRel RelWithDebInfo)
## END: Generating AboutThisBuild.txt
# link witz bzip # link witz bzip
if (WITH_BZIP) if (WITH_BZIP)

14
tools/generateReleaseInfo Executable file
View File

@@ -0,0 +1,14 @@
#!/usr/bin/env bash
hgBranch="`hg branch`"
hgLatesttag="`hg parents --template '{latesttag}'`"
hgLatesttagdistance="`hg parents --template '{latesttagdistance}'`"
hgChangeset="`hg parents --template '{node|short}'`"
echo "set(HG_BRANCH $hgBranch)
set(HG_VERSION $hgLatesttag.$hgLatesttagdistance)
set(HG_CHANGESET $hgChangeset)
set(HG_TAGDISTANCE $hgLatesttagdistance)
if (CACHE_NAME_SUFFIX STREQUAL \"\")
set(CACHE_NAME_SUFFIX $hgLatesttag)
endif()" > ReleaseInfo.cmake

View File

@@ -0,0 +1,14 @@
@echo off
for /f "tokens=*" %%a in ('hg branch') do @set hgBranch=%%a
for /f "tokens=*" %%a in ('hg parents --template "{latesttag}"') do @set hgLatesttag=%%a
for /f "tokens=*" %%a in ('hg parents --template "{latesttagdistance}"') do @set hgLatesttagdistance=%%a
for /f "tokens=*" %%a in ('hg parents --template "{node|short}"') do @set hgChangeset=%%a
echo set(HG_BRANCH %hgBranch%) > ReleaseInfo.cmake
echo set(HG_VERSION %hgLatesttag%.%hgLatesttagdistance%) >> ReleaseInfo.cmake
echo set(HG_CHANGESET %hgChangeset%) >> ReleaseInfo.cmake
echo set(HG_TAGDISTANCE %hgLatesttagdistance%) >> ReleaseInfo.cmake
echo if (CACHE_NAME_SUFFIX STREQUAL "") >> ReleaseInfo.cmake
echo set(CACHE_NAME_SUFFIX %hgLatesttag%) >> ReleaseInfo.cmake
echo endif() >> ReleaseInfo.cmake