diff --git a/Installation/cmake/modules/CGAL_CreateSingleSourceCGALProgram.cmake b/Installation/cmake/modules/CGAL_CreateSingleSourceCGALProgram.cmake index 58b5bd6e384..281b513764b 100644 --- a/Installation/cmake/modules/CGAL_CreateSingleSourceCGALProgram.cmake +++ b/Installation/cmake/modules/CGAL_CreateSingleSourceCGALProgram.cmake @@ -1,7 +1,7 @@ function(create_single_source_cgal_program firstfile ) if(NOT IS_ABSOLUTE "${firstfile}") - set(firstfile "${CMAKE_CURRENT_SOURCE_DIR}/${firstfile}") + set(firstfile "${CGAL_CURRENT_SOURCE_DIR}/${firstfile}") endif() get_filename_component(exe_name ${firstfile} NAME_WE) @@ -12,14 +12,14 @@ function(create_single_source_cgal_program firstfile ) # remaining files foreach( i ${ARGN} ) - set( all ${all} ${CMAKE_CURRENT_SOURCE_DIR}/${i} ) + set( all ${all} ${CGAL_CURRENT_SOURCE_DIR}/${i} ) endforeach() add_executable(${exe_name} ${all}) if(BUILD_TESTING) - set(cin_file "${CMAKE_CURRENT_SOURCE_DIR}/${exe_name}.cin") + set(cin_file "${CGAL_CURRENT_SOURCE_DIR}/${exe_name}.cin") if(EXISTS ${cin_file}) add_test(NAME ${exe_name} COMMAND ${CMAKE_COMMAND} @@ -30,7 +30,7 @@ function(create_single_source_cgal_program firstfile ) else() # TODO: deal with shell globbing; if the `cmd` file contains # a `*`, then interprete the command using bash. - set(cmd_file "${CMAKE_CURRENT_SOURCE_DIR}/${exe_name}.cmd") + set(cmd_file "${CGAL_CURRENT_SOURCE_DIR}/${exe_name}.cmd") if(EXISTS ${cmd_file}) file(STRINGS "${cmd_file}" CMD_LINES) set(ARGS) @@ -38,7 +38,7 @@ function(create_single_source_cgal_program firstfile ) foreach(CMD_LINE ${CMD_LINES}) # message(STATUS " command line: ${CMD_LINE}") separate_arguments(CMD_LINE_ARGS UNIX_COMMAND ${CMD_LINE}) - # message(STATUS " args: ${CMD_LINE_ARGS}") +# message(STATUS " args: ${CMD_LINE_ARGS}") list(APPEND ARGS ${CMD_LINE_ARGS}) endforeach() endif() @@ -47,8 +47,9 @@ function(create_single_source_cgal_program firstfile ) endif() set_property(TEST "${exe_name}" APPEND PROPERTY LABELS "${PROJECT_NAME}") +# message(STATUS " workding dir: ${CGAL_CURRENT_SOURCE_DIR}") set_property(TEST "${exe_name}" - PROPERTY WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + PROPERTY WORKING_DIRECTORY ${CGAL_CURRENT_SOURCE_DIR}) endif(BUILD_TESTING) add_to_cached_list( CGAL_EXECUTABLE_TARGETS ${exe_name} ) diff --git a/Installation/cmake/modules/UseCGAL.cmake b/Installation/cmake/modules/UseCGAL.cmake index 814d4bfbc06..259fb97b451 100644 --- a/Installation/cmake/modules/UseCGAL.cmake +++ b/Installation/cmake/modules/UseCGAL.cmake @@ -9,6 +9,11 @@ include(${CGAL_MODULES_DIR}/CGAL_Macros.cmake) cgal_setup_module_path() +# Save the current source directory. That variable can be changed by +# a `CMakeLists.txt`, for `CMakeLists.txt` files that are created in +# the binary directory. +set(CGAL_CURRENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + if(NOT USE_CGAL_FILE_INCLUDED) set(USE_CGAL_FILE_INCLUDED 1) diff --git a/Scripts/scripts/cgal_create_cmake_script b/Scripts/scripts/cgal_create_cmake_script index b39812fa1d7..d31102227d2 100755 --- a/Scripts/scripts/cgal_create_cmake_script +++ b/Scripts/scripts/cgal_create_cmake_script @@ -58,6 +58,10 @@ if ( CGAL_FOUND ) include( CGAL_CreateSingleSourceCGALProgram ) EOF + if [ -d "${SOURCE_DIR}" ] ; then + echo " set(CGAL_CURRENT_SOURCE_DIR \"${SOURCE_DIR}\")" + echo + fi if [ -d "${SOURCE_DIR}../../include" ] ; then echo " include_directories (BEFORE \"${SOURCE_DIR}../../include\")" echo