Modernize the CMakeLists.txt that use LEDA

The file `${CGAL_USE_FILE}` must be included before
`find_package(LEDA)` can be called. But that would require to verify
`CGAL_FOUND` first...

Actually, now that we require at least CMake 3.1, let's say that CGAL
is `REQUIRED`, but not the components. That is the basic truth, and
that avoids testing for `CGAL_FOUND`.

At the same time, I have modified the `cmake_minimum_required`:
  - placed as the first line,
  - set to `3.1...3.13`:
      https://cmake.org/cmake/help/latest/command/cmake_policy.html#setting-policies-by-cmake-version

I have also removed the comments that says the `CMakeLists.txt` was
generated. That may have been true... but before a lot of modifications.
This commit is contained in:
Laurent Rineau 2019-03-27 09:56:16 +01:00
parent 0c0d5e1cfb
commit d4e09c1d78
8 changed files with 57 additions and 87 deletions

View File

@ -1,16 +1,12 @@
# Created by the script cgal_create_cmake_script cmake_minimum_required(VERSION 3.1...3.13)
# This is the CMake script for compiling a CGAL application.
project( Cone_spanners_2_Examples ) project( Cone_spanners_2_Examples )
cmake_minimum_required(VERSION 3.1) find_package(CGAL REQUIRED QUIET OPTIONAL_COMPONENTS Core)
include(${CGAL_USE_FILE})
find_package(CGAL QUIET COMPONENTS Core)
find_package(LEDA QUIET) find_package(LEDA QUIET)
if ( CGAL_FOUND AND ( CGAL_Core_FOUND OR LEDA_FOUND ) ) if ( CGAL_Core_FOUND OR LEDA_FOUND )
include(${CGAL_USE_FILE})
if (MSVC) if (MSVC)
# Turn off a boost related warning that appears with VC2015 # Turn off a boost related warning that appears with VC2015
# boost_1_65_1\boost\graph\named_function_params.hpp(240) : # boost_1_65_1\boost\graph\named_function_params.hpp(240) :
@ -26,7 +22,7 @@ if ( CGAL_FOUND AND ( CGAL_Core_FOUND OR LEDA_FOUND ) )
else() else()
message(STATUS "This program requires the CGAL and CGAL_Core libraries, and will not be compiled.") message(STATUS "This program requires the CGAL_Core library (or LEDA), and will not be compiled.")
endif() endif()

View File

@ -1,3 +1,5 @@
cmake_minimum_required(VERSION 3.1...3.13)
project (Hyperbolic_triangulation_2_Demo) project (Hyperbolic_triangulation_2_Demo)
# Find includes in corresponding build directories # Find includes in corresponding build directories
@ -6,9 +8,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed. # Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)
cmake_minimum_required(VERSION 3.1...3.13) find_package(CGAL REQUIRED QUIET OPTIONAL_COMPONENTS Core Qt5)
find_package(CGAL QUIET COMPONENTS Core Qt5)
find_package(LEDA QUIET) find_package(LEDA QUIET)
find_package(Qt5 QUIET COMPONENTS Widgets) find_package(Qt5 QUIET COMPONENTS Widgets)
@ -25,5 +25,5 @@ if(CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND AND (CGAL_Core_FOUND OR LEDA_FOUN
add_executable ( HDT2_demo HDT2.cpp ${CGAL_Qt5_RESOURCE_FILES} ${RESOURCE_FILES} ${UIS}) add_executable ( HDT2_demo HDT2.cpp ${CGAL_Qt5_RESOURCE_FILES} ${RESOURCE_FILES} ${UIS})
target_link_libraries ( HDT2_demo CGAL::CGAL CGAL::CGAL_Qt5 CGAL::CGAL_Core Qt5::Widgets) target_link_libraries ( HDT2_demo CGAL::CGAL CGAL::CGAL_Qt5 CGAL::CGAL_Core Qt5::Widgets)
else() else()
message(STATUS "NOTICE: This demo requires CGAL, CGAL_Core, and Qt5 and will not be compiled.") message(STATUS "NOTICE: This demo requires CGAL, CGAL_Core (or LEDA), and Qt5 and will not be compiled.")
endif() endif()

View File

@ -1,16 +1,12 @@
# Created by the script cgal_create_cmake_script cmake_minimum_required(VERSION 3.1...3.13)
# This is the CMake script for compiling a CGAL application.
project( Periodic_4_hyperbolic_triangulation_2_Examples ) project( Periodic_4_hyperbolic_triangulation_2_Examples )
cmake_minimum_required(VERSION 2.8.10) find_package(CGAL REQUIRED QUIET OPTIONAL_COMPONENTS Core )
find_package(CGAL QUIET COMPONENTS Core )
find_package(LEDA QUIET)
if ( CGAL_FOUND AND (CGAL_Core_FOUND OR LEDA_FOUND) )
include( ${CGAL_USE_FILE} ) include( ${CGAL_USE_FILE} )
find_package(LEDA QUIET)
if ( CGAL_Core_FOUND OR LEDA_FOUND )
include( CGAL_CreateSingleSourceCGALProgram ) include( CGAL_CreateSingleSourceCGALProgram )

View File

@ -31,7 +31,6 @@
#include <CGAL/Bbox_2.h> #include <CGAL/Bbox_2.h>
#include <CGAL/Cartesian.h> #include <CGAL/Cartesian.h>
#include <CGAL/CORE_Expr.h>
#include <boost/tuple/tuple.hpp> #include <boost/tuple/tuple.hpp>
#include <boost/variant.hpp> #include <boost/variant.hpp>

View File

@ -1,18 +1,13 @@
# Created by the script cgal_create_cmake_script cmake_minimum_required(VERSION 3.1...3.13)
# This is the CMake script for compiling a CGAL application.
project( Periodic_4_hyperbolic_triangulation_2_Tests ) project( Periodic_4_hyperbolic_triangulation_2_Tests )
cmake_minimum_required(VERSION 2.8.10) find_package(CGAL REQUIRED QUIET OPTIONAL_COMPONENTS Core )
include( ${CGAL_USE_FILE} )
find_package(CGAL QUIET COMPONENTS Core )
find_package(LEDA QUIET) find_package(LEDA QUIET)
if ( CGAL_FOUND AND (CGAL_Core_FOUND OR LEDA_FOUND) ) if ( CGAL_FOUND AND (CGAL_Core_FOUND OR LEDA_FOUND) )
include( ${CGAL_USE_FILE} )
include( CGAL_CreateSingleSourceCGALProgram ) include( CGAL_CreateSingleSourceCGALProgram )
create_single_source_cgal_program( "test_p4ht2_construct_point_2.cpp" ) create_single_source_cgal_program( "test_p4ht2_construct_point_2.cpp" )

View File

@ -99,6 +99,8 @@ create_cmake_script_with_options()
# Created by the script cgal_create_CMakeLists # Created by the script cgal_create_CMakeLists
# This is the CMake script for compiling a set of CGAL applications. # This is the CMake script for compiling a set of CGAL applications.
cmake_minimum_required(VERSION 3.1...3.13)
EOF EOF
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
if [ "$SINGLE_SOURCE" = "n" ]; then if [ "$SINGLE_SOURCE" = "n" ]; then
@ -111,8 +113,6 @@ EOF
cat << 'EOF' cat << 'EOF'
cmake_minimum_required(VERSION 2.8.11)
# CGAL and its components # CGAL and its components
EOF EOF
if [ -n "$ENABLE_CTEST" ]; then if [ -n "$ENABLE_CTEST" ]; then
@ -172,7 +172,7 @@ fi
fi fi
echo "find_package( CGAL QUIET COMPONENTS ${CGAL_COMPONENTS//:/ } )" echo "find_package( CGAL REQUIRED QUIET OPTIONAL_COMPONENTS ${CGAL_COMPONENTS//:/ } )"
#vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv #vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
cat << 'EOF' cat << 'EOF'

View File

@ -40,19 +40,17 @@ create_cmake_script()
# Created by the script cgal_create_cmake_script # Created by the script cgal_create_cmake_script
# This is the CMake script for compiling a CGAL application. # This is the CMake script for compiling a CGAL application.
cmake_minimum_required(VERSION 3.1...3.13)
project( ${PROJECT}_${TYPE} ) project( ${PROJECT}_${TYPE} )
EOF EOF
cat <<'EOF' cat <<'EOF'
cmake_minimum_required(VERSION 2.8.10)
set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD 14)
EOF EOF
cat <<'EOF' cat <<'EOF'
find_package(CGAL QUIET COMPONENTS Core ) find_package(CGAL REQUIRED QUIET OPTIONAL_COMPONENTS Core )
if ( CGAL_FOUND ) if ( CGAL_FOUND )

View File

@ -1,18 +1,13 @@
# Created by the script cgal_create_cmake_script cmake_minimum_required(VERSION 3.1...3.13)
# This is the CMake script for compiling a CGAL application.
project( Surface_mesh_shortest_path_Tests ) project( Surface_mesh_shortest_path_Tests )
cmake_minimum_required(VERSION 3.1) find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Core)
find_package(CGAL QUIET COMPONENTS Core)
find_package(LEDA QUIET)
if ( CGAL_FOUND )
include(${CGAL_USE_FILE}) include(${CGAL_USE_FILE})
find_package(LEDA QUIET)
include_directories (BEFORE "include") include_directories (BEFORE "include")
create_single_source_cgal_program( "Surface_mesh_shortest_path_test_1.cpp" ) create_single_source_cgal_program( "Surface_mesh_shortest_path_test_1.cpp" )
@ -21,7 +16,6 @@ if ( CGAL_FOUND )
create_single_source_cgal_program( "Surface_mesh_shortest_path_test_4.cpp" ) create_single_source_cgal_program( "Surface_mesh_shortest_path_test_4.cpp" )
create_single_source_cgal_program( "Surface_mesh_shortest_path_traits_test.cpp" ) create_single_source_cgal_program( "Surface_mesh_shortest_path_traits_test.cpp" )
# Link with Boost.ProgramOptions (optional) # Link with Boost.ProgramOptions (optional)
find_package(Boost QUIET COMPONENTS program_options) find_package(Boost QUIET COMPONENTS program_options)
if(Boost_PROGRAM_OPTIONS_FOUND) if(Boost_PROGRAM_OPTIONS_FOUND)
@ -35,16 +29,8 @@ if ( CGAL_FOUND )
if(CGAL_Core_FOUND OR LEDA_FOUND) if(CGAL_Core_FOUND OR LEDA_FOUND)
create_single_source_cgal_program( "TestMesh.cpp" ) create_single_source_cgal_program( "TestMesh.cpp" )
else() else()
message(STATUS "NOTICE: Example TestMesh.cpp requires CGAL_Core library and will not be compiled.") message(STATUS "NOTICE: Example TestMesh.cpp requires the CGAL_Core library (or LEDA) and will not be compiled.")
endif() endif()
else() else()
message(STATUS "NOTICE: Example TestMesh.cpp requires boost program_option and will not be compiled.") message(STATUS "NOTICE: Example TestMesh.cpp requires boost program_option and will not be compiled.")
endif() endif()
else()
message(STATUS "This program requires the CGAL library, and will not be compiled.")
endif()