aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2018-03-12 09:48:00 +0100
committerThomas White <taw@physics.org>2018-03-12 10:17:49 +0100
commit753ceccfb4517ae0aa4445c18ae34ca52171f28d (patch)
treea2928d9de6f10813b97363ea401cc72625ed3ce2 /CMakeLists.txt
parent95bb73d90fed58f61dddc0d1d3e8afeb9879daaa (diff)
Add CMake
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt361
1 files changed, 361 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 00000000..530c5320
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,361 @@
+cmake_minimum_required(VERSION 3.6)
+project(crystfel)
+
+include(GNUInstallDirs)
+
+option(BUILD_HDFSEE "Build hdfsee" ON)
+option(BUILD_EXPLORER "Build the cell_explorer" ON)
+
+# Set CMAKE_MODULE_PATH to assist cmake in finding our own package definitions
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMake")
+
+find_package(HDF5 REQUIRED COMPONENTS C)
+find_package(Threads REQUIRED)
+find_package(GSL REQUIRED)
+find_package(GTK2 2.0.0 COMPONENTS gtk)
+find_package(FFTW)
+find_package(CBF)
+find_package(TIFF)
+find_package(Cairo)
+find_package(XGANDALF)
+find_package(PINKINDEXER)
+find_package(NBP)
+find_package(FDIP)
+find_package(OpenCL)
+
+include(config)
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+add_definitions(-DHAVE_CONFIG_H -DDATADIR=\"${CMAKE_INSTALL_FULL_DATADIR}\")
+set(CMAKE_C_STANDARD 99)
+
+# Make programs work without LD_LIBRARY_PATH when installed to a non system directory
+list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
+if("${isSystemDir}" STREQUAL "-1")
+ set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
+endif("${isSystemDir}" STREQUAL "-1")
+
+# Common include directories and libraries
+
+set(COMMON_INCLUDES
+ ${HDF5_INCLUDE_DIRS}
+ )
+
+set(COMMON_LIBRARIES
+ libcrystfel
+ ${HDF5_C_LIBRARIES}
+ Threads::Threads
+ GSL::gsl
+ )
+
+
+# Add the libcrystfel target
+add_subdirectory(libcrystfel)
+add_custom_target(
+ versionh
+ BYPRODUCTS ${CMAKE_SOURCE_DIR}/version.h
+ COMMAND ${CMAKE_SOURCE_DIR}/version.sh ${CMAKE_SOURCE_DIR}
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ )
+add_dependencies(libcrystfel versionh)
+
+# ----------------------------------------------------------------------
+# Build Target
+# partial_sim
+
+set(PARTIAL_SIM_SOURCES
+ src/partial_sim.c)
+
+add_executable(partial_sim ${PARTIAL_SIM_SOURCES})
+target_include_directories(partial_sim PRIVATE ${COMMON_INCLUDES})
+target_link_libraries(partial_sim ${COMMON_LIBRARIES})
+
+# ----------------------------------------------------------------------
+# Build Target
+# pattern_sim
+
+set(PATTERN_SIM_SOURCES
+ src/pattern_sim.c
+ src/diffraction.c
+ )
+
+if(HAVE_OPENCL)
+ set(PATTERN_SIM_OPENCL_SOURCES
+ src/cl-utils.c
+ src/diffraction-gpu.c
+ )
+ set(PATTERN_SIM_RESOURCE_FILES
+ data/diffraction.cl
+ )
+endif(HAVE_OPENCL)
+
+add_executable(pattern_sim ${PATTERN_SIM_SOURCES} ${PATTERN_SIM_OPENCL_SOURCES})
+target_include_directories(pattern_sim PRIVATE ${COMMON_INCLUDES})
+target_link_libraries(pattern_sim ${COMMON_LIBRARIES})
+
+if(HAVE_OPENCL)
+ target_include_directories(pattern_sim PRIVATE ${OpenCL_INCLUDE_DIRS})
+ target_link_libraries(pattern_sim ${OpenCL_LIBRARIES})
+endif(HAVE_OPENCL)
+
+set_target_properties(pattern_sim PROPERTIES
+ RESOURCE "${PATTERN_SIM_RESOURCE_FILES}"
+ )
+
+# ----------------------------------------------------------------------
+# Build Target
+# hdfsee
+
+if(BUILD_HDFSEE AND GTK2_FOUND AND TIFF_FOUND)
+
+ set(HDFSEE_SOURCES
+ src/hdfsee.c
+ src/dw-hdfsee.c
+ src/hdfsee-render.c
+ )
+
+ set(HDFSEE_RESOURCE_FILES
+ data/hdfsee.ui
+ )
+
+ add_executable(hdfsee ${HDFSEE_SOURCES})
+ target_include_directories(hdfsee PRIVATE
+ ${COMMON_INCLUDES}
+ ${GTK2_INCLUDE_DIRS}
+ )
+ target_link_libraries(hdfsee
+ ${COMMON_LIBRARIES}
+ TIFF::TIFF
+ ${GTK2_LIBRARIES}
+ )
+ set_target_properties(hdfsee PROPERTIES
+ RESOURCE "${HDFSEE_RESOURCE_FILES}"
+ )
+
+ install(
+ TARGETS
+ hdfsee
+
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ RESOURCE DESTINATION share/crystfel
+ )
+
+endif(BUILD_HDFSEE AND GTK2_FOUND AND TIFF_FOUND)
+
+# ----------------------------------------------------------------------
+# Build Target
+# cell_explorer
+
+if(BUILD_EXPLORER AND GTK2_FOUND)
+
+ set(CELL_EXPLORER_SOURCES
+ src/cell_explorer.c
+ src/multihistogram.c
+ )
+
+ add_executable(cell_explorer ${CELL_EXPLORER_SOURCES})
+ target_include_directories(cell_explorer PRIVATE ${COMMON_INCLUDES} ${GTK2_INCLUDE_DIRS})
+ target_link_libraries(cell_explorer ${COMMON_LIBRARIES} ${GTK2_LIBRARIES})
+
+ install(
+ TARGETS
+ cell_explorer
+
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ )
+
+endif(BUILD_EXPLORER AND GTK2_FOUND)
+
+# ----------------------------------------------------------------------
+# Build Target
+# render_hkl
+
+if(CAIRO_FOUND AND GTK2_FOUND)
+
+ set(RENDER_HKL_SOURCES
+ src/render_hkl.c
+ )
+
+ add_executable(render_hkl ${RENDER_HKL_SOURCES})
+ target_include_directories(render_hkl PRIVATE
+ ${COMMON_INCLUDES}
+ ${GTK2_INCLUDE_DIRS}
+ ${CAIRO_INCLUDE_DIRS}
+ )
+ target_link_libraries(render_hkl
+ ${COMMON_LIBRARIES}
+ ${GTK2_LIBRARIES}
+ ${CAIRO_LIBRARIES}
+ )
+
+ install(
+ TARGETS
+ render_hkl
+
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ )
+endif(CAIRO_FOUND AND GTK2_FOUND)
+
+# ----------------------------------------------------------------------
+# Build Target
+# process_hkl
+
+set(PROCESS_HKL_SOURCES
+ src/process_hkl.c
+ )
+
+add_executable(process_hkl ${PROCESS_HKL_SOURCES})
+target_include_directories(process_hkl PRIVATE ${COMMON_INCLUDES})
+target_link_libraries(process_hkl ${COMMON_LIBRARIES})
+
+# ----------------------------------------------------------------------
+# Build Target
+# list_events
+
+set(LIST_EVENTS_SOURCES
+ src/list_events.c
+ )
+
+add_executable(list_events ${LIST_EVENTS_SOURCES})
+target_include_directories(list_events PRIVATE ${COMMON_INCLUDES})
+target_link_libraries(list_events ${COMMON_LIBRARIES})
+
+# ----------------------------------------------------------------------
+# Build Target
+# indexamajig
+
+set(INDEXAMAJIG_SOURCES
+ src/indexamajig.c
+ src/im-sandbox.c
+ src/process_image.c
+ src/time-accounts.c
+ )
+
+add_executable(indexamajig ${INDEXAMAJIG_SOURCES})
+target_include_directories(indexamajig PRIVATE ${COMMON_INCLUDES})
+target_link_libraries(indexamajig ${COMMON_LIBRARIES})
+
+# ----------------------------------------------------------------------
+# Build Target
+# get_hkl
+
+set(GET_HKL_SOURCES
+ src/get_hkl.c
+ )
+
+add_executable(get_hkl ${GET_HKL_SOURCES})
+target_include_directories(get_hkl PRIVATE ${COMMON_INCLUDES})
+target_link_libraries(get_hkl ${COMMON_LIBRARIES})
+
+# ----------------------------------------------------------------------
+# Build Target
+# compare_hkl
+
+set(COMPARE_HKL_SOURCES
+ src/compare_hkl.c
+ )
+
+add_executable(compare_hkl ${COMPARE_HKL_SOURCES})
+target_include_directories(compare_hkl PRIVATE ${COMMON_INCLUDES})
+target_link_libraries(compare_hkl ${COMMON_LIBRARIES})
+
+# ----------------------------------------------------------------------
+# Build Target
+# check_hkl
+
+set(CHECK_HKL_SOURCES
+ src/check_hkl.c
+ )
+
+add_executable(check_hkl ${CHECK_HKL_SOURCES})
+target_include_directories(check_hkl PRIVATE ${COMMON_INCLUDES})
+target_link_libraries(check_hkl ${COMMON_LIBRARIES})
+
+# ----------------------------------------------------------------------
+# Build Target
+# partialator
+
+set(PARTIALATOR_SOURCES
+ src/partialator.c
+ src/post-refinement.c
+ src/merge.c
+ src/rejection.c
+ src/scaling.c
+ )
+
+add_executable(partialator ${PARTIALATOR_SOURCES})
+target_include_directories(partialator PRIVATE ${COMMON_INCLUDES})
+target_link_libraries(partialator ${COMMON_LIBRARIES})
+
+# ----------------------------------------------------------------------
+# Build Target
+# ambigator
+
+set(AMBIGATOR_SOURCES
+ src/ambigator.c
+ )
+
+add_executable(ambigator ${AMBIGATOR_SOURCES})
+target_include_directories(ambigator PRIVATE ${COMMON_INCLUDES})
+target_link_libraries(ambigator ${COMMON_LIBRARIES})
+
+# ----------------------------------------------------------------------
+# Build Target
+# geoptimizer
+
+if (CAIRO_FOUND AND GTK2_FOUND AND TIFF_FOUND)
+ set(GEOPTIMIZER_SOURCES
+ src/geoptimiser.c
+ src/hdfsee-render.c
+ )
+
+ add_executable(geoptimizer ${GEOPTIMIZER_SOURCES})
+ target_include_directories(geoptimizer PRIVATE ${COMMON_INCLUDES} ${CAIRO_INCLUDE_DIRS} ${GTK2_INCLUDE_DIRS})
+ target_link_libraries(geoptimizer ${COMMON_LIBRARIES} ${CAIRO_LIBRARIES} ${GTK2_LIBRARIES} ${TIFF_LIBRARIES})
+
+ install(
+ TARGETS
+ geoptimizer
+
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ )
+endif (CAIRO_FOUND AND GTK2_FOUND AND TIFF_FOUND)
+
+# ----------------------------------------------------------------------
+# Build Target
+# geoptimizer
+
+set(WHIRLIGIG_SOURCES
+ src/whirligig.c
+ )
+
+add_executable(whirligig ${WHIRLIGIG_SOURCES})
+target_include_directories(whirligig PRIVATE ${COMMON_INCLUDES})
+target_link_libraries(whirligig ${COMMON_LIBRARIES})
+
+
+# install targets
+
+install(
+ TARGETS
+ partial_sim
+ pattern_sim
+ process_hkl
+ list_events
+ indexamajig
+ get_hkl
+ compare_hkl
+ check_hkl
+ partialator
+ ambigator
+ whirligig
+
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ RESOURCE DESTINATION share/crystfel
+ )
+