From 3cefeeb23c60423d75f6ec508bcd16891173b74e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 11 Feb 2021 19:18:57 +0100 Subject: [PATCH] set CGAL_DATA_DIR in CGALconfig.cmake --- Installation/CMakeLists.txt | 3 +-- .../cmake/modules/CGAL_add_test.cmake | 4 +--- Installation/lib/cmake/CGAL/CGALConfig.cmake | 22 +++++++++++++++++++ 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Installation/CMakeLists.txt b/Installation/CMakeLists.txt index 09decb19645..7184d702d03 100644 --- a/Installation/CMakeLists.txt +++ b/Installation/CMakeLists.txt @@ -50,13 +50,12 @@ if (NOT CGAL_DATA_DIR) set(CGAL_DATA_DIR "${CMAKE_SOURCE_DIR}/Data/data") else() message("CMAKE_SOURCE_DIR = ${CMAKE_SOURCE_DIR}") - message(FATAL_ERROR "CGAL_DATA_DIR cannot be deduced, please set the variable CGAL_DATA_DIR") + message(WARNING "CGAL_DATA_DIR cannot be deduced, set the variable CGAL_DATA_DIR to set the default value of CGAL::data_file_path()") endif() endif() endif() endif() -set(CGAL_DATA_DIR "${CMAKE_SOURCE_DIR}/Data/data" CACHE STRING "Directory containing the Data files") if ( NOT "${CGAL_DATA_DIR}" STREQUAL "" ) add_definitions(-DCGAL_DATA_DIR="${CGAL_DATA_DIR}") endif() diff --git a/Installation/cmake/modules/CGAL_add_test.cmake b/Installation/cmake/modules/CGAL_add_test.cmake index 6f6762959e7..2750150b95f 100644 --- a/Installation/cmake/modules/CGAL_add_test.cmake +++ b/Installation/cmake/modules/CGAL_add_test.cmake @@ -330,14 +330,12 @@ function(cgal_add_test exe_name) if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../../Data/data") set(CGAL_DATA_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../Data/data") else() - message(FATAL_ERROR "CGAL_DATA_DIR cannot be deduced, please set the variable CGAL_DATA_DIR") + message(WARNING "CGAL_DATA_DIR cannot be deduced, set the variable CGAL_DATA_DIR to set the default value of CGAL::data_file_path()") endif() endif() endif() endif() - message(STATUS "Using CGAL_DATA_DIR = ${CGAL_DATA_DIR}") - file(STRINGS "${cmd_file}" CMD_LINES) string(CONFIGURE "${CMD_LINES}" CMD_LINES) set(ARGS) diff --git a/Installation/lib/cmake/CGAL/CGALConfig.cmake b/Installation/lib/cmake/CGAL/CGALConfig.cmake index 92f6a884000..a9d7e582857 100644 --- a/Installation/lib/cmake/CGAL/CGALConfig.cmake +++ b/Installation/lib/cmake/CGAL/CGALConfig.cmake @@ -167,4 +167,26 @@ if( CGAL_DEV_MODE OR RUNNING_CGAL_AUTO_TEST ) set(CMAKE_NO_SYSTEM_FROM_IMPORTED TRUE) endif() +#set CGAL_DATA_DIR +if (NOT CGAL_DATA_DIR) + if(DEFINED ENV{CGAL_DATA_DIR}) + set(CGAL_DATA_DIR $ENV{CGAL_DATA_DIR}) + else() + if (EXISTS "${CGAL_ROOT}/data") + set(CGAL_DATA_DIR "${CGAL_ROOT}/data") + else() + if (EXISTS "${CGAL_ROOT}/Data/data") + set(CGAL_DATA_DIR "${CGAL_ROOT}/Data/data") + else() + message("CMAKE_SOURCE_DIR = ${CGAL_ROOT}") + message(WARNING "CGAL_DATA_DIR cannot be deduced, set the variable CGAL_DATA_DIR to set the default value of CGAL::data_file_path()") + endif() + endif() + endif() +endif() + +if ( NOT "${CGAL_DATA_DIR}" STREQUAL "" ) + add_definitions(-DCGAL_DATA_DIR="${CGAL_DATA_DIR}") +endif() + include("${CGAL_MODULES_DIR}/CGAL_enable_end_of_configuration_hook.cmake")