Files
cgal/Installation/cmake/modules/UseCGAL.cmake
T
Laurent Rineau 545e80f18e 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).
2016-09-20 10:53:20 +02:00

71 lines
2.3 KiB
CMake

#
# UseCGAL.cmake can be included in a project to set the needed compiler and linker
# settings to use CGAL in a program.
#
# The variables used here are defined in the CGALConfig.cmake generated when CGAL was installed.
#
#
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)
include(CGAL_Common)
include(CGAL_SetupFlags)
include(CGAL_GeneratorSpecificSettings)
include(CGAL_TweakFindBoost)
set(CGAL_INSTALLED_SCM_BRANCH_NAME ${CGAL_SCM_BRANCH_NAME})
set(CGAL_SCM_BRANCH_NAME "")
if( NOT "${CGAL_INSTALLED_SCM_BRANCH_NAME}" STREQUAL "" )
include(CGAL_SCM)
if ( NOT "${CGAL_SCM_BRANCH_NAME}" STREQUAL "" )
message ( STATUS "Code taken from Git branch: ${CGAL_SCM_BRANCH_NAME}" )
if ( NOT "${CGAL_SCM_BRANCH_NAME}" STREQUAL "${CGAL_INSTALLED_SCM_BRANCH_NAME}")
message (AUTHOR_WARNING "Branch '${CGAL_SCM_BRANCH_NAME}' does not match branch '${CGAL_INSTALLED_SCM_BRANCH_NAME}' from which CGAL has been installed. Please consider rebuilding CGAL from this branch.")
endif()
endif()
endif()
set( CGAL_LIBRARIES )
foreach ( component ${CGAL_REQUESTED_COMPONENTS} )
use_component( ${component} )
endforeach()
use_essential_libs()
include_directories( "${CMAKE_CURRENT_BINARY_DIR}" )
if(TARGET CGAL)
add_to_list( CGAL_LIBRARIES CGAL )
else()
add_to_list( CGAL_LIBRARIES ${CGAL_LIBRARY} )
endif()
#message (STATUS "LIB: ${CGAL_LIBRARY}")
#message (STATUS "LIBS: ${CGAL_LIBRARIES}")
include_directories ( ${CGAL_INCLUDE_DIRS})
include_directories ( SYSTEM ${CGAL_3RD_PARTY_INCLUDE_DIRS} )
add_definitions ( ${CGAL_3RD_PARTY_DEFINITIONS} ${CGAL_DEFINITIONS} )
if (CGAL_HEADER_ONLY)
add_definitions(-DCGAL_HEADER_ONLY)
link_directories ( ${CGAL_3RD_PARTY_LIBRARIES_DIRS} )
link_libraries ( ${CGAL_3RD_PARTY_LIBRARIES} )
else()
link_directories ( ${CGAL_LIBRARIES_DIR} ${CGAL_3RD_PARTY_LIBRARIES_DIRS} )
link_libraries ( ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES} )
endif()
endif()