From 41251065c26059f7189b6627330cfc15cb6aa5f7 Mon Sep 17 00:00:00 2001 From: Fernando Cacciola Date: Wed, 27 Aug 2008 16:24:01 +0000 Subject: [PATCH] Fix pending problems with examples and demos (now possible to do 'make examples' or 'make demo' from CGAL_DIR) --- Installation/CMakeLists.txt | 46 ++++++++++++------- Installation/cmake/modules/CGALcommon.cmake | 13 ++++++ .../CreateSingleSourceCGALProgram.cmake | 13 ++++-- .../CreateSingleSourceCGALQt3Program.cmake | 8 ++-- .../CreateSingleSourceCGALQt4Program.cmake | 8 ++-- Scripts/scripts/cgal_create_cmake_script | 2 + 6 files changed, 62 insertions(+), 28 deletions(-) diff --git a/Installation/CMakeLists.txt b/Installation/CMakeLists.txt index b1e23fcfe77..67e8a17babc 100644 --- a/Installation/CMakeLists.txt +++ b/Installation/CMakeLists.txt @@ -71,6 +71,7 @@ message( STATUS "CGAL_MINOR_VERSION=${CGAL_MINOR_VERSION}" ) message( STATUS "CGAL_BUILD_VERSION=${CGAL_BUILD_VERSION}" ) set( CGAL_SOVERSION "3.0.0" ) + message( STATUS "CGAL_SOVERSION=${CGAL_SOVERSION}" ) #-------------------------------------------------------------------------------------------------- @@ -79,10 +80,10 @@ message( STATUS "CGAL_SOVERSION=${CGAL_SOVERSION}" ) # #-------------------------------------------------------------------------------------------------- -set(CGAL_3RD_PARTY_DEFINITIONS "" CACHE INTERNAL "" ) -set(CGAL_3RD_PARTY_INCLUDE_DIRS "" CACHE INTERNAL "" ) -set(CGAL_3RD_PARTY_LIBRARIES "" CACHE INTERNAL "" ) -set(CGAL_3RD_PARTY_LIBRARIES_DIR "" CACHE INTERNAL "" ) +cache_set(CGAL_3RD_PARTY_DEFINITIONS "" ) +cache_set(CGAL_3RD_PARTY_INCLUDE_DIRS "" ) +cache_set(CGAL_3RD_PARTY_LIBRARIES "" ) +cache_set(CGAL_3RD_PARTY_LIBRARIES_DIR "" ) # This module finds dependent libraries: Boost, GMP, CORE, etc.. @@ -126,9 +127,9 @@ foreach(config_test_cpp ${all_config_tests}) CHECK_CXX_FILE_RUNS(${config_test_cpp} ${config_test_name} ${config_test_name}) if ( ${config_test_name} ) - set ( ${config_test_name} 0 CACHE INTERNAL "" FORCE ) + cache_set ( ${config_test_name} 0 ) else() - set ( ${config_test_name} 1 CACHE INTERNAL "" FORCE ) + cache_set ( ${config_test_name} 1 ) endif() endif() @@ -213,8 +214,7 @@ endif() set(CGAL_LIBRARIES_DIR ${CMAKE_BINARY_DIR}/lib) -set(CGAL_LIBRARIES "" CACHE STRING "Selected CGAL Libraries") -hide_variable(CGAL_LIBRARIES) +cache_set(CGAL_LIBRARIES "" ) set(CGAL_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/include ${CMAKE_SOURCE_DIR}/include) @@ -238,13 +238,10 @@ include(CGAL_SetupFlags) add_subdirectory(src) -# -# load cache values from subdirectories above -# -set(CGAL_3RD_PARTY_DEFINITIONS ) -set(CGAL_3RD_PARTY_INCLUDE_DIRS ) -set(CGAL_3RD_PARTY_LIBRARIES ) -set(CGAL_3RD_PARTY_LIBRARIES_DIR) +cache_get(CGAL_3RD_PARTY_DEFINITIONS ) +cache_get(CGAL_3RD_PARTY_INCLUDE_DIRS ) +cache_get(CGAL_3RD_PARTY_LIBRARIES ) +cache_get(CGAL_3RD_PARTY_LIBRARIES_DIR) set( CGAL_LIBRARIES ${CGAL_CORE_LIBRARY} ${CGAL_LIBRARY} ${CGAL_IMAGEIO_LIBRARY} ${CGAL_PDB_LIBRARY} ${CGAL_QT_LIBRARY} ) @@ -328,14 +325,29 @@ endif() # #-------------------------------------------------------------------------------------------------- +macro( add_programs subdir ON_OFF ) + + cache_set( CGAL_EXECUTABLES "" ) + + add_custom_target( ${subdir} ) + + optional_add_subdirectory( ${subdir} ${ON_OFF} EXCLUDE_FROM_ALL ) + + cache_get( CGAL_EXECUTABLES ) + + foreach( CGAL_EXECUTABLE in ${CGAL_EXECUTABLES} ) + add_dependencies( ${subdir} ${CGAL_EXECUTABLE} ) + endforeach() + +endmacro() # This allows programs to locate CGALConfig.cmake set(CGAL_DIR ${CMAKE_BINARY_DIR} ) if ( NOT RUNNING_CGAL_AUTO_TEST ) - optional_add_subdirectory( demo OFF EXCLUDE_FROM_ALL ) - optional_add_subdirectory( examples ON EXCLUDE_FROM_ALL ) + add_programs(examples ON ) + add_programs(demo OFF ) endif() diff --git a/Installation/cmake/modules/CGALcommon.cmake b/Installation/cmake/modules/CGALcommon.cmake index ccf17d98ef9..ba460f179a3 100644 --- a/Installation/cmake/modules/CGALcommon.cmake +++ b/Installation/cmake/modules/CGALcommon.cmake @@ -24,6 +24,19 @@ if( NOT CGAL_COMMON_FILE_INCLUDED ) set ( ${var} ${${var}} CACHE INTERNAL "Variable hidden from user" FORCE ) endmacro() + macro( cache_set var value ) + set ( ${var} ${value} CACHE INTERNAL "" FORCE ) + endmacro() + + macro( cache_get var ) + set ( ${var} ) + endmacro() + + macro( add_to_cached_list listname item ) + cache_get ( ${listname} ) + cache_set ( ${listname} "${${listname}};${item}" ) + endmacro() + macro( at list idx var ) list( LENGTH ${list} ${list}_length ) if ( ${idx} LESS ${${list}_length} ) diff --git a/Installation/cmake/modules/CreateSingleSourceCGALProgram.cmake b/Installation/cmake/modules/CreateSingleSourceCGALProgram.cmake index 52b4aedd52b..bb66e581e6d 100644 --- a/Installation/cmake/modules/CreateSingleSourceCGALProgram.cmake +++ b/Installation/cmake/modules/CreateSingleSourceCGALProgram.cmake @@ -1,16 +1,19 @@ macro(create_single_source_cgal_program first ) - if(EXISTS ${CMAKE_SOURCE_DIR}/${first}) - set( all ${CMAKE_SOURCE_DIR}/${first} ) + if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${first}) + + set( all ${CMAKE_CURRENT_SOURCE_DIR}/${first} ) foreach( i ${ARGN} ) - set( all ${all} ${CMAKE_SOURCE_DIR}/${i} ) + set( all ${all} ${CMAKE_CURRENT_SOURCE_DIR}/${i} ) endforeach() get_filename_component(exe_name ${first} NAME_WE) - add_executable (${exe_name} ${all}) - + add_executable(${exe_name} ${all}) + + add_to_cached_list( CGAL_EXECUTABLES ${exe_name} ) + # Link the executable to CGAL and third-party libraries if ( AUTO_LINK_ENABLED ) target_link_libraries(${exe_name} ${CGAL_3RD_PARTY_LIBRARIES} ) diff --git a/Installation/cmake/modules/CreateSingleSourceCGALQt3Program.cmake b/Installation/cmake/modules/CreateSingleSourceCGALQt3Program.cmake index c1c186a1796..21b21e0961f 100644 --- a/Installation/cmake/modules/CreateSingleSourceCGALQt3Program.cmake +++ b/Installation/cmake/modules/CreateSingleSourceCGALQt3Program.cmake @@ -1,10 +1,10 @@ macro(create_single_source_cgal_qt3_program first ) - if(EXISTS ${CMAKE_SOURCE_DIR}/${first}) - set( all ${CMAKE_SOURCE_DIR}/${first} ) + if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${first}) + set( all ${CMAKE_CURRENT_SOURCE_DIR}/${first} ) foreach( i ${ARGN} ) - set( all ${all} ${CMAKE_SOURCE_DIR}/${i} ) + set( all ${all} ${CMAKE_CURRENT_SOURCE_DIR}/${i} ) endforeach() get_filename_component(exe_name ${first} NAME_WE) @@ -18,6 +18,8 @@ macro(create_single_source_cgal_qt3_program first ) include_directories( ${QT_INCLUDE_DIR} ) add_executable (${exe_name} ${all}) + + add_to_cached_list( CGAL_EXECUTABLES ${exe_name} ) # Link the executable to CGAL and third-party libraries if ( AUTO_LINK_ENABLED ) diff --git a/Installation/cmake/modules/CreateSingleSourceCGALQt4Program.cmake b/Installation/cmake/modules/CreateSingleSourceCGALQt4Program.cmake index ddce0f268d5..d1b7b71acae 100644 --- a/Installation/cmake/modules/CreateSingleSourceCGALQt4Program.cmake +++ b/Installation/cmake/modules/CreateSingleSourceCGALQt4Program.cmake @@ -1,10 +1,10 @@ macro(create_single_source_cgal_qt4_program first ) - if(EXISTS ${CMAKE_SOURCE_DIR}/${first}) - set( all ${CMAKE_SOURCE_DIR}/${first} ) + if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${first}) + set( all ${CMAKE_CURRENT_SOURCE_DIR}/${first} ) foreach( i ${ARGN} ) - set( all ${all} ${CMAKE_SOURCE_DIR}/${i} ) + set( all ${all} ${CMAKE_CURRENT_SOURCE_DIR}/${i} ) endforeach() get_filename_component(exe_name ${first} NAME_WE) @@ -17,6 +17,8 @@ macro(create_single_source_cgal_qt4_program first ) add_executable (${exe_name} ${all}) + add_to_cached_list( CGAL_EXECUTABLES ${exe_name} ) + # Link the executable to CGAL and third-party libraries if ( AUTO_LINK_ENABLED ) target_link_libraries(${exe_name} ${CGAL_3RD_PARTY_LIBRARIES} ${QT_LIBRARIES} ) diff --git a/Scripts/scripts/cgal_create_cmake_script b/Scripts/scripts/cgal_create_cmake_script index 6eac6b70736..8f76f0e441b 100755 --- a/Scripts/scripts/cgal_create_cmake_script +++ b/Scripts/scripts/cgal_create_cmake_script @@ -87,6 +87,8 @@ create_cmake_script() echo "add_executable (${exe_name} ${all})" echo + echo "add_to_cached_list( CGAL_EXECUTABLES ${exe_name} )" + echo echo '# Link the executable to CGAL and third-party libraries' echo 'if ( AUTO_LINK_ENABLED )'