Skip to content

Commit

Permalink
Merge pull request darktable-org#1162 from LebedevRI/cmake-issues
Browse files Browse the repository at this point in the history
CMake fixes: part 2. Fixes darktable-org#10354
  • Loading branch information
LebedevRI committed Mar 3, 2016
2 parents db08ec3 + c9857b8 commit 590ceed
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 24 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
project(darktable CXX C)
cmake_minimum_required(VERSION 2.6)
cmake_policy(VERSION 2.6)

project(darktable CXX C)

# Allow forcing the C/CPP compiler that is actually used during the compilation
# to something other than what is used by the cmake run. This is useful when
Expand Down
24 changes: 14 additions & 10 deletions data/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,13 @@ configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/darktableconfig.dtd ${CMAKE_CURRENT_


if(USE_XMLLINT)
execute_process(
COMMAND ${Xmllint_BIN} --valid ${CMAKE_CURRENT_BINARY_DIR}/darktableconfig.xml
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/
OUTPUT_QUIET ERROR_QUIET
RESULT_VARIABLE Xmllint_RES
)
if(NOT ${Xmllint_RES} EQUAL 0 )
message(FATAL_ERROR "data/darktableconfig.xml is not valid")
endif(NOT ${Xmllint_RES} EQUAL 0 )
add_custom_target(
validate_darktableconfig_xml ALL
COMMAND ${Xmllint_BIN} --valid --noout ${CMAKE_CURRENT_BINARY_DIR}/darktableconfig.xml
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/darktableconfig.xml
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
COMMENT "Checking validity of data/darktableconfig.xml"
)
endif(USE_XMLLINT)

if(NOT ${Xsltproc_BIN} STREQUAL "Xsltproc_BIN-NOTFOUND")
Expand All @@ -127,7 +125,13 @@ else(NOT ${Xsltproc_BIN} STREQUAL "Xsltproc_BIN-NOTFOUND")
endif(NOT ${Saxon_BIN} STREQUAL "Saxon_BIN-NOTFOUND")
endif(NOT ${Xsltproc_BIN} STREQUAL "Xsltproc_BIN-NOTFOUND")

add_custom_target(darktablerc_file ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/darktablerc)
add_custom_target(
darktablerc_file ALL
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../tools/generate_darktablerc.xsl ${CMAKE_CURRENT_BINARY_DIR}/darktableconfig.dtd ${CMAKE_CURRENT_BINARY_DIR}/darktableconfig.xml ${CMAKE_CURRENT_BINARY_DIR}/darktablerc
)
if(USE_XMLLINT)
add_dependencies(darktablerc_file validate_darktableconfig_xml)
endif(USE_XMLLINT)

# first of all install darktablerc file into share as template
# postinst script should copy this into users homedirectory
Expand Down
3 changes: 3 additions & 0 deletions doc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ else(NOT ${Xsltproc_BIN} STREQUAL "Xsltproc_BIN-NOTFOUND")
endif(NOT ${Xsltproc_BIN} STREQUAL "Xsltproc_BIN-NOTFOUND")

add_custom_target(darktablerc.html_file ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/darktablerc.html)
if(USE_XMLLINT)
add_dependencies(darktablerc.html_file validate_darktableconfig_xml)
endif(USE_XMLLINT)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/darktablerc.html DESTINATION ${SHARE_INSTALL}/doc/darktable)

Expand Down
23 changes: 19 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -686,37 +686,52 @@ if(NOT ${Xsltproc_BIN} STREQUAL "Xsltproc_BIN-NOTFOUND")
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../tools/generate_prefs.xsl ${CMAKE_CURRENT_BINARY_DIR}/../data/darktableconfig.dtd ${CMAKE_CURRENT_BINARY_DIR}/../data/darktableconfig.xml
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/preferences_gen.h
COMMAND ${Xsltproc_BIN} --stringparam HAVE_OPENCL ${HAVE_OPENCL} ${CMAKE_CURRENT_SOURCE_DIR}/../tools/generate_prefs.xsl ${CMAKE_CURRENT_BINARY_DIR}/../data/darktableconfig.xml > ${CMAKE_CURRENT_BINARY_DIR}/preferences_gen.h
COMMENT "Generating preferences"
)
else(NOT ${Xsltproc_BIN} STREQUAL "Xsltproc_BIN-NOTFOUND")
if(NOT ${Saxon_BIN} STREQUAL "Saxon_BIN-NOTFOUND")
add_custom_command(
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../tools/generate_prefs.xsl ${CMAKE_CURRENT_BINARY_DIR}/../data/darktableconfig.dtd ${CMAKE_CURRENT_BINARY_DIR}/../data/darktableconfig.xml
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/preferences_gen.h
COMMAND ${Saxon_BIN} ${CMAKE_CURRENT_BINARY_DIR}/../data/darktableconfig.xml ${CMAKE_CURRENT_SOURCE_DIR}/../tools/generate_prefs.xsl HAVE_OPENCL=${HAVE_OPENCL} > ${CMAKE_CURRENT_BINARY_DIR}/preferences_gen.h
COMMENT "Generating preferences"
)
else(NOT ${Saxon_BIN} STREQUAL "Saxon_BIN-NOTFOUND")
message(FATAL_ERROR "Don't know how to generate preferences")
endif(NOT ${Saxon_BIN} STREQUAL "Saxon_BIN-NOTFOUND")
endif(NOT ${Xsltproc_BIN} STREQUAL "Xsltproc_BIN-NOTFOUND")

add_custom_target(
generate_preferences ALL
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../tools/generate_prefs.xsl ${CMAKE_CURRENT_BINARY_DIR}/../data/darktableconfig.dtd ${CMAKE_CURRENT_BINARY_DIR}/../data/darktableconfig.xml ${CMAKE_CURRENT_BINARY_DIR}/preferences_gen.h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
if(USE_XMLLINT)
add_dependencies(generate_preferences validate_darktableconfig_xml)
endif(USE_XMLLINT)

#
# Generate mapping of key strings to internal metadata id
#
add_custom_command(
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../tools/create_metadata.sh ${CMAKE_CURRENT_SOURCE_DIR}/../tools/metadata.txt
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/metadata_gen.h ${CMAKE_CURRENT_BINARY_DIR}/metadata_gen.c
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/../tools/create_metadata.sh ${CMAKE_CURRENT_SOURCE_DIR}/../tools/metadata.txt ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating metadata .c/.h"
)
add_custom_target(
generate_metadata ALL
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../tools/create_metadata.sh ${CMAKE_CURRENT_SOURCE_DIR}/../tools/metadata.txt ${CMAKE_CURRENT_BINARY_DIR}/metadata_gen.h ${CMAKE_CURRENT_BINARY_DIR}/metadata_gen.c
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)

# this is a dummy library whose sole purpose is to serve as a dependency for subdirs, such as imageio/storage/gallery.
# cmake can't depend on custom targets in other directories than the current one.
add_library(metadata_dummy ${CMAKE_CURRENT_BINARY_DIR}/metadata_gen.c ${CMAKE_CURRENT_BINARY_DIR}/metadata_gen.h)

#
# build libdarktable
#
add_library(lib_darktable SHARED ${CMAKE_CURRENT_BINARY_DIR}/preferences_gen.h ${CMAKE_CURRENT_BINARY_DIR}/metadata_gen.h ${CMAKE_CURRENT_BINARY_DIR}/metadata_gen.c ${SOURCES})
add_dependencies(lib_darktable generate_version)
add_dependencies(lib_darktable generate_preferences)
add_dependencies(lib_darktable generate_metadata)

if(APPLE)
set_target_properties(lib_darktable PROPERTIES MACOSX_RPATH TRUE)
Expand Down
15 changes: 8 additions & 7 deletions src/external/rawspeed/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
cmake_minimum_required(VERSION 2.6)

if(USE_XMLLINT)
execute_process(
COMMAND ${Xmllint_BIN} --valid ${CMAKE_CURRENT_SOURCE_DIR}/data/cameras.xml
add_custom_target(
validate_cameras_xml ALL
COMMAND ${Xmllint_BIN} --valid --noout ${CMAKE_CURRENT_SOURCE_DIR}/data/cameras.xml
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/data/cameras.xml
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
OUTPUT_QUIET ERROR_QUIET
RESULT_VARIABLE Xmllint_RES
COMMENT "Checking validity of external/rawspeed/data/cameras.xml"
)
if(NOT ${Xmllint_RES} EQUAL 0 )
message(FATAL_ERROR "external/rawspeed/data/cameras.xml is not valid")
endif(NOT ${Xmllint_RES} EQUAL 0 )
endif(USE_XMLLINT)

install(FILES data/cameras.xml data/showcameras.xsl DESTINATION ${SHARE_INSTALL}/darktable/rawspeed)
Expand Down Expand Up @@ -40,6 +38,9 @@ endif()

add_definitions(-std=c++11)
add_library(rawspeed STATIC ${RAWSPEED_SOURCES})
if(USE_XMLLINT)
add_dependencies(rawspeed validate_cameras_xml)
endif(USE_XMLLINT)
target_link_libraries(rawspeed ${RAWSPEED_LIBS})

# Adapted from src/cli/CMakeLists.txt
Expand Down
2 changes: 1 addition & 1 deletion src/imageio/storage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ endif(JsonGlib_FOUND)

foreach(module ${MODULES})
add_library(${module} MODULE "${module}.c")
add_dependencies(${module} generate_metadata)
endforeach(module)
add_dependencies(gallery metadata_dummy)

foreach(module ${MODULES})
target_link_libraries(${module} ${LIBS})
Expand Down

0 comments on commit 590ceed

Please sign in to comment.