CMakeLists.txt (4520B)
1 # Copyright (C) 2015-2016 CNRS 2 # 3 # This program is free software: you can redistribute it and/or modify 4 # it under the terms of the GNU General Public License as published by 5 # the Free Software Foundation, either version 3 of the License, or 6 # (at your option) any later version. 7 # 8 # This program is distributed in the hope that it will be useful, 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 # GNU General Public License for more details. 12 # 13 # You should have received a copy of the GNU General Public License 14 # along with this program. If not, see <http://www.gnu.org/licenses/>. 15 16 cmake_minimum_required(VERSION 2.8) 17 enable_testing() 18 project(schiff C) 19 20 set(SCHIFF_SOURCE_DIR ${PROJECT_SOURCE_DIR}/../src/) 21 22 ################################################################################ 23 # Check dependencies 24 ################################################################################ 25 get_filename_component(_current_source_dir ${CMAKE_CURRENT_LIST_FILE} PATH) 26 set(LibYAML_DIR ${_current_source_dir}/) 27 28 find_package(LibYAML REQUIRED) 29 find_package(RCMake 0.2 REQUIRED) 30 find_package(RSys 0.3 REQUIRED) 31 find_package(Star3D 0.3 REQUIRED) 32 find_package(StarSchiff 0.3 REQUIRED) 33 find_package(StarSP 0.3 REQUIRED) 34 if(MSVC) 35 find_package(MuslGetopt REQUIRED) 36 include_directories(${MuslGetopt_INCLUDE_DIR}) 37 endif() 38 39 include_directories( 40 ${LibYAML_INCLUDE_DIR} 41 ${RSys_INCLUDE_DIR} 42 ${Star3D_INCLUDE_DIR} 43 ${StarSchiff_INCLUDE_DIR} 44 ${StarSP_INCLUDE_DIR}) 45 46 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${RCMAKE_SOURCE_DIR}) 47 include(rcmake) 48 include(rcmake_runtime) 49 50 ################################################################################ 51 # Configure and define the targets 52 ################################################################################ 53 set(VERSION_MAJOR 0) 54 set(VERSION_MINOR 3) 55 set(VERSION_PATCH 1) 56 set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) 57 58 set(SCHIFF_FILES_SRC 59 schiff.c 60 schiff_args.c 61 schiff_geometry.c 62 schiff_mesh.c 63 schiff_optical_properties.c) 64 set(SCHIFF_FILES_INC 65 schiff_args.h 66 schiff_geometry.h 67 schiff_mesh.h 68 schiff_optical_properties.h 69 schiff_streamline.h) 70 set(SCHIFF_FILES_DOC COPYING README.md) 71 set(SCHIFF_FILES_MAN1 schiff.1) 72 set(SCHIFF_FILES_MAN5 schiff-geometry.5 schiff-output.5) 73 74 # Prepend each file in the `SCHIFF_FILES_<SRC|INC>' list by the absolute 75 # path of the directory in which they lie 76 rcmake_prepend_path(SCHIFF_FILES_SRC ${SCHIFF_SOURCE_DIR}) 77 rcmake_prepend_path(SCHIFF_FILES_INC ${SCHIFF_SOURCE_DIR}) 78 rcmake_prepend_path(SCHIFF_FILES_DOC ${PROJECT_SOURCE_DIR}/../) 79 rcmake_prepend_path(SCHIFF_FILES_MAN1 ${PROJECT_SOURCE_DIR}/../doc/) 80 rcmake_prepend_path(SCHIFF_FILES_MAN5 ${PROJECT_SOURCE_DIR}/../doc/) 81 82 if(CMAKE_COMPILER_IS_GNUCC) 83 set(MATH_LIB m) 84 endif() 85 86 add_executable(schiff ${SCHIFF_FILES_SRC} ${SCHIFF_FILES_INC}) 87 target_link_libraries(schiff LibYAML RSys Star3D StarSchiff StarSP ${MATH_LIB}) 88 if(MSVC) 89 target_link_libraries(schiff MuslGetopt) 90 endif() 91 set_target_properties(schiff PROPERTIES 92 VERSION ${VERSION} 93 SOVERSION ${VERSION_MAJOR}) 94 rcmake_copy_runtime_libraries(schiff) 95 96 ################################################################################ 97 # Tests 98 ################################################################################ 99 # Check that the following command exists 100 find_program(_bash bash) 101 find_program(_bc bc) 102 find_program(_csplit csplit) 103 find_program(_env env) 104 105 if(NOT _bash OR NOT _bc OR NOT _csplit OR NOT _env) 106 message(WARNING "Cannot setup the bash test script") 107 else() 108 add_test( 109 NAME test_schiff_cylinder 110 COMMAND 111 ${_env} PATH=$ENV{PATH}:$<TARGET_FILE_DIR:schiff> 112 ${_bash} ${SCHIFF_SOURCE_DIR}/test_schiff_cylinder.sh) 113 add_test( 114 NAME test_schiff_sphere 115 COMMAND 116 ${_env} PATH=$ENV{PATH}:$<TARGET_FILE_DIR:schiff> 117 ${_bash} ${SCHIFF_SOURCE_DIR}/test_schiff_sphere.sh 118 WORKING_DIRECTORY ${_test_sphere_path}) 119 endif() 120 121 ################################################################################ 122 # Define output & install directories 123 ################################################################################ 124 install(TARGETS schiff 125 ARCHIVE DESTINATION bin 126 LIBRARY DESTINATION lib 127 RUNTIME DESTINATION bin) 128 install(FILES ${SCHIFF_FILES_DOC} DESTINATION share/doc/schiff) 129 install(FILES ${SCHIFF_FILES_MAN1} DESTINATION share/man/man1) 130 install(FILES ${SCHIFF_FILES_MAN5} DESTINATION share/man/man5) 131 rcmake_install_runtime_libraries(schiff) 132