mirror of https://github.com/CGAL/cgal
Add a variable CGAL_CURRENT_SOURCE_DIR
Save the current source directory to `CGAL_CURRENT_SOURCE_DIR`. The variable value is modified by a `CMakeLists.txt` file when it is generated by `cgal_create_cmake_script` in the binary tree. The script `cgal_create_cmake_script` itself it called by CMake, by the function `process_CGAL_subdirectory` (see its definition in `Installation/cmake/modules/CGAL_Macros.cmake`), called in `(examples|test|demo)/CMakeLists.txt`. Eventually, that variable value is supposed to be the directory to the current sources, even if the current `CMakeLists.txt` is within the binary tree. That is used in `CGAL_CreateSingleSourceCGALProgram.cmake` for the CTest support, so set correctly the current working directory (in the directory of the tests/examples).
This commit is contained in:
parent
c30560143b
commit
545e80f18e
|
|
@ -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)
|
||||
|
|
@ -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} )
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue