Add an option to check the syntax of headers, individually.

That feature can be enabled with g++, clang++, and icpc (intel). It could
be implemented for MSVC, with the flag /Zs, but that is not yet done (and
probably will not).

The option is controlled by a CMake option, CGAL_ENABLE_CHECK_HEADERS, that
is disabled by default. If that option is enabled by the user, then CMake
will check if the compiler $CXX understand the syntax:
  $CXX -x c++ -fsyntax-only CGAL/header.h
and send an error otherwise.

Then phony targets will be created:
  - a target check_CGAL__header_h for each header <CGAL/header.h>,
  - a target check_pkg_<pkg> for each package <pgk>,
  - and a target check_headers for the whole CGAL.

Those new targets currently give a lot of compilation errors if
CGAL_ENABLE_CHECK_HEADERS is enabled!

+ fix several missing includes in Mesh_2.
This commit is contained in:
Laurent Rineau 2012-10-05 12:21:44 +00:00
parent 9230a787f1
commit 0a081c2abd
5 changed files with 65 additions and 0 deletions

View File

@ -948,3 +948,63 @@ if( WITH_CPACK AND EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake" )
endif()
if ( CGAL_BRANCH_BUILD )
option(CGAL_ENABLE_CHECK_HEADERS
"Enable the special targets \"check_pkg_headers\", and \"check_pkg_<package>_headers\" for each package"
FALSE)
if(CGAL_ENABLE_CHECK_HEADERS)
if(NOT DEFINED CGAL_CHECK_SYNTAX_ONLY)
execute_process(COMMAND
${CMAKE_CXX_COMPILER} -x c++ -fsyntax-only ${CMAKE_CURRENT_SOURCE_DIR}/config/support/test_syntaxonly.cpp
ERROR_QUIET
RESULT_VARIABLE ok)
if(ok EQUAL 0)
set(CGAL_CHECK_SYNTAX_ONLY ON CACHE INTERNAL "")
else()
set(CGAL_CHECK_SYNTAX_ONLY OFF CACHE INTERNAL "")
endif()
endif(NOT DEFINED CGAL_CHECK_SYNTAX_ONLY)
if(NOT CGAL_CHECK_SYNTAX_ONLY)
message(FATAL_ERROR "Your compiler does not seem to support -fsyntax-only.
You must disable CGAL_ENABLE_CHECK_HEADERS.")
endif()
## Fill the variable include_options with all the -I and -isystem options
set(include_options)
foreach (incdir ${CGAL_INCLUDE_DIRS})
list(APPEND include_options "-I${incdir}")
endforeach()
foreach (incdir ${CGAL_3RD_PARTY_INCLUDE_DIRS})
list(APPEND include_options "-isystem${incdir}")
endforeach()
include_directories ( SYSTEM ${CGAL_3RD_PARTY_INCLUDE_DIRS} )
## Loop on package and headers
set(check_pkg_target_list)
foreach (package ${CGAL_CONFIGURED_PACKAGES_NAMES})
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../${package}/include)
set(depends "")
file(GLOB_RECURSE ${package}_HEADERS
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/../${package}/include"
"${CMAKE_CURRENT_SOURCE_DIR}/../${package}/include/*.h")
foreach(header ${${package}_HEADERS})
string(REPLACE "/" "__" header2 "${header}")
string(REPLACE "." "_" header2 "${header2}")
add_custom_target(check_${header2}
COMMAND ${CMAKE_CXX_COMPILER} ${CGAL_3RD_PARTY_DEFINITIONS} ${CGAL_DEFINITIONS} ${include_options} -x c++ -fsyntax-only "${CMAKE_CURRENT_SOURCE_DIR}/../${package}/include/${header}"
VERBATIM
COMMENT "Check header ${header}"
)
list(APPEND depends check_${header2})
endforeach() # look on headers
add_custom_target(check_pkg_${package}_headers DEPENDS ${depends})
list(APPEND check_pkg_target_list check_pkg_${package}_headers)
endif() # if the package has an include directory
endforeach() # loop on packages
add_custom_target(check_headers DEPENDS ${check_pkg_target_list})
endif()
endif( CGAL_BRANCH_BUILD )

View File

@ -24,6 +24,8 @@
#include <CGAL/Mesher_level.h>
#include <CGAL/Meshes/Triangulation_mesher_level_traits_2.h>
#include <CGAL/Meshes/Filtered_queue_container.h>
#include <CGAL/tags.h>
#include <CGAL/assertions.h>
#include <utility>
#include <iterator>

View File

@ -21,6 +21,8 @@
#ifndef CGAL_MESHER_LEVEL_H
#define CGAL_MESHER_LEVEL_H
#include <string>
namespace CGAL {
enum Mesher_level_conflict_status {

View File

@ -24,6 +24,7 @@
#include <vector>
#include <CGAL/Mesher_level.h>
#include <CGAL/Mesher_level_default_implementations.h>
#include <CGAL/tags.h>
namespace CGAL {