diff --git a/Installation/cmake/modules/CGAL_CreateSingleSourceCGALProgram.cmake b/Installation/cmake/modules/CGAL_CreateSingleSourceCGALProgram.cmake index efcfd97d9d2..21a6685544a 100644 --- a/Installation/cmake/modules/CGAL_CreateSingleSourceCGALProgram.cmake +++ b/Installation/cmake/modules/CGAL_CreateSingleSourceCGALProgram.cmake @@ -4,23 +4,24 @@ function(create_single_source_cgal_program firstfile ) set(firstfile "${CMAKE_CURRENT_SOURCE_DIR}/${firstfile}") endif() + get_filename_component(exe_name ${firstfile} NAME_WE) + if(EXISTS "${firstfile}") - + set( all "${firstfile}" ) - + # remaining files foreach( i ${ARGN} ) - set( all ${all} ${CMAKE_CURRENT_SOURCE_DIR}/${i} ) + set( all ${all} ${CMAKE_CURRENT_SOURCE_DIR}/${i} ) endforeach() - - get_filename_component(exe_name ${firstfile} NAME_WE) + add_executable(${exe_name} ${all}) - + add_to_cached_list( CGAL_EXECUTABLE_TARGETS ${exe_name} ) - + # Link the executable to CGAL and third-party libraries - if ( CGAL_AUTO_LINK_ENABLED ) + if ( CGAL_AUTO_LINK_ENABLED ) target_link_libraries(${exe_name} ${CGAL_3RD_PARTY_LIBRARIES} ) @@ -29,7 +30,8 @@ function(create_single_source_cgal_program firstfile ) target_link_libraries(${exe_name} ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES} ) endif() - + else() + message(AUTHOR_WARNING "The executable ${exe_name} will not be created because the source file ${firstfile} does not exist.") endif() - + endfunction()