cgal/Installation/test/Installation/CMakeLists.txt

145 lines
4.6 KiB
CMake

# Created by the script cgal_create_cmake_script
# This is the CMake script for compiling a CGAL application.
project( Installation_Tests )
cmake_minimum_required(VERSION 3.1)
macro(create_link_to_program COMPONENT )
add_executable(link_to_${COMPONENT} link_to_${COMPONENT}.cpp )
include_directories ( ${${COMPONENT}_3RD_PARTY_INCLUDE_DIRS} )
add_definitions( ${${COMPONENT}_3RD_PARTY_DEFINITIONS} )
link_directories( ${${COMPONENT}_3RD_PARTY_LIBRARIES_DIRS})
# Link the executable to CGAL and third-party libraries
if ( CGAL_AUTO_LINK_ENABLED OR CGAL_HEADER_ONLY)
target_link_libraries(link_to_${COMPONENT} ${CGAL_3RD_PARTY_LIBRARIES} ${${COMPONENT}_3RD_PARTY_LIBRARIES} )
else()
target_link_libraries(link_to_${COMPONENT} CGAL::${COMPONENT} ${CGAL_3RD_PARTY_LIBRARIES} ${${COMPONENT}_3RD_PARTY_LIBRARIES} )
endif()
add_to_cached_list( CGAL_EXECUTABLE_TARGETS link_to_${COMPONENT} )
endmacro()
find_package(CGAL QUIET COMPONENTS Core)
if ( CGAL_FOUND )
include( ${CGAL_USE_FILE} )
include( CGAL_CreateSingleSourceCGALProgram )
create_single_source_cgal_program( "endian.cpp" )
create_single_source_cgal_program( "deprecation_warning.cpp" )
create_single_source_cgal_program( "test_use_h.cpp" )
create_single_source_cgal_program( will_fail.cpp will_fail_aux.cpp )
if(BUILD_TESTING)
set_property(TEST execution___of__will_fail PROPERTY WILL_FAIL TRUE)
endif()
find_package( TBB QUIET )
create_single_source_cgal_program( "test_TBB.cpp" )
if(TBB_FOUND)
CGAL_target_use_TBB(test_TBB)
endif()
create_link_to_program(CGAL)
if ( WITH_CGAL_Core )
create_link_to_program(CGAL_Core)
endif()
if ( WITH_CGAL_ImageIO )
create_link_to_program(CGAL_ImageIO)
endif()
if ( WITH_CGAL_Qt4 )
find_package(Qt4 QUIET)
if( QT4_FOUND )
include(${QT_USE_FILE})
create_link_to_program(CGAL_Qt4)
endif()
endif()
if ( WITH_CGAL_Qt5 )
find_package(Qt5 QUIET)
if( Qt5_FOUND )
create_link_to_program(CGAL_Qt5)
if (CGAL_HEADER_ONLY)
qt5_use_modules(link_to_CGAL_Qt5)
endif()
endif()
endif()
if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL Windows)
add_executable(display_dll_version_info display_dll_version_info.cpp)
target_link_libraries(display_dll_version_info version)
add_executable(test_gmp_mpfr_dll test_gmp_mpfr_dll.cpp)
target_link_libraries(test_gmp_mpfr_dll version)
CGAL_add_test(test_gmp_mpfr_dll)
add_to_cached_list( CGAL_EXECUTABLE_TARGETS test_gmp_mpfr_dll )
endif()
find_package( LEDA QUIET)
if(LEDA_FOUND)
include( ${LEDA_USE_FILE} )
add_executable(test_LEDA_IO test_LEDA_IO.cpp)
target_link_libraries(test_LEDA_IO ${LEDA_LIBRARIES})
endif()
else()
message(STATUS "NOTICE: This program requires the CGAL library, and will not be compiled.")
endif()
function(CGAL_installation_test_find_package_version mode)
set(EXACT)
if(mode STREQUAL "less")
set(CGAL_MINOR_VERSION 0)
endif()
if(mode STREQUAL "less_major")
set(CGAL_MAJOR_VERSION 0)
endif()
if(mode STREQUAL "greater" OR mode STREQUAL "fail-exact")
MATH(EXPR CGAL_MINOR_VERSION "${CGAL_MINOR_VERSION} + 1")
endif()
if(mode STREQUAL "exact" OR mode STREQUAL "fail-exact")
set(EXACT "EXACT ")
endif()
if (CGAL_BUGFIX_VERSION AND CGAL_BUGFIX_VERSION GREATER 0)
set(VERSION "${CGAL_MAJOR_VERSION}.${CGAL_MINOR_VERSION}.${CGAL_BUGFIX_VERSION}")
else()
set(VERSION "${CGAL_MAJOR_VERSION}.${CGAL_MINOR_VERSION}")
endif()
file(REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/build-test_find_package_version_${mode}")
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/build-test_find_package_version_${mode})
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test_find_package_version_${mode})
configure_file(test_find_package.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/test_find_package_version_${mode}/CMakeLists.txt)
add_test(NAME test_find_package_version_${mode}
COMMAND ${CMAKE_COMMAND} -S ${CMAKE_CURRENT_BINARY_DIR}/test_find_package_version_${mode} -B ${CMAKE_CURRENT_BINARY_DIR}/build-test_find_package_version_${mode})
cgal_setup_test_properties(test_find_package_version_${mode})
endfunction()
CGAL_installation_test_find_package_version(less)
CGAL_installation_test_find_package_version(less_major)
CGAL_installation_test_find_package_version(equal)
CGAL_installation_test_find_package_version(greater)
CGAL_installation_test_find_package_version(exact)
CGAL_installation_test_find_package_version(fail-exact)
set_tests_properties(
test_find_package_version_greater
test_find_package_version_less_major
test_find_package_version_fail-exact
PROPERTIES WILL_FAIL TRUE)