Skip to content
Snippets Groups Projects
Commit d4a97f5a authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

fix old cmake warnings related to EXCLUDE_FROM_ALL targets for which we provide an install rule

(the fix is the "cmake way" according to Bill Hoffman: add a config option to decide if we build the optional targets or not)
parent f9aad7b3
No related branches found
No related tags found
No related merge requests found
...@@ -29,6 +29,8 @@ option(ENABLE_BAMG "Enable Bamg mesh generator" ${DEFAULT}) ...@@ -29,6 +29,8 @@ option(ENABLE_BAMG "Enable Bamg mesh generator" ${DEFAULT})
option(ENABLE_BFGS "Enable BFGS" ${DEFAULT}) option(ENABLE_BFGS "Enable BFGS" ${DEFAULT})
option(ENABLE_BLAS_LAPACK "Use BLAS and Lapack for linear algebra" ON) option(ENABLE_BLAS_LAPACK "Use BLAS and Lapack for linear algebra" ON)
option(ENABLE_BLOSSOM "Enable Blossom algo (based on MATCH and concorde97)" ${DEFAULT}) option(ENABLE_BLOSSOM "Enable Blossom algo (based on MATCH and concorde97)" ${DEFAULT})
option(ENABLE_BUILD_LIB "Build static Gmsh library" OFF)
option(ENABLE_BUILD_SHARED "Build shared Gmsh library" OFF)
option(ENABLE_CGNS "Enable CGNS mesh export" OFF) option(ENABLE_CGNS "Enable CGNS mesh export" OFF)
option(ENABLE_CHACO "Enable Chaco mesh partitioner" ${DEFAULT}) option(ENABLE_CHACO "Enable Chaco mesh partitioner" ${DEFAULT})
option(ENABLE_DINTEGRATION "Enable discrete integration and levelsets" ${DEFAULT}) option(ENABLE_DINTEGRATION "Enable discrete integration and levelsets" ${DEFAULT})
...@@ -66,7 +68,7 @@ option(ENABLE_TETGEN "Enable Tetgen mesh generator" ${DEFAULT}) ...@@ -66,7 +68,7 @@ option(ENABLE_TETGEN "Enable Tetgen mesh generator" ${DEFAULT})
option(ENABLE_TETGEN_OLD "Use old version of Tetgen" OFF) option(ENABLE_TETGEN_OLD "Use old version of Tetgen" OFF)
option(ENABLE_VORO3D "Enable Voro3D" ${DEFAULT}) option(ENABLE_VORO3D "Enable Voro3D" ${DEFAULT})
option(ENABLE_WRAP_JAVA "Build Java wrappers" OFF) option(ENABLE_WRAP_JAVA "Build Java wrappers" OFF)
option(ENABLE_WRAP_PYTHON "Build Python wrappers" ${DEFAULT}) option(ENABLE_WRAP_PYTHON "Build Python wrappers" OFF)
set(GMSH_MAJOR_VERSION 2) set(GMSH_MAJOR_VERSION 2)
set(GMSH_MINOR_VERSION 6) set(GMSH_MINOR_VERSION 6)
...@@ -89,15 +91,17 @@ set(GMSH_API ...@@ -89,15 +91,17 @@ set(GMSH_API
Geo/GFace.h Geo/GRegion.h Geo/GEdgeLoop.h Geo/GEdgeCompound.h Geo/GFace.h Geo/GRegion.h Geo/GEdgeLoop.h Geo/GEdgeCompound.h
Geo/GFaceCompound.h Geo/GRegionCompound.h Geo/GRbf.h Geo/MVertex.h Geo/GFaceCompound.h Geo/GRegionCompound.h Geo/GRbf.h Geo/MVertex.h
Geo/MVertexBoundaryLayerData.h Geo/MEdge.h Geo/MVertexBoundaryLayerData.h Geo/MEdge.h
Geo/MFace.h Geo/MElement.h Geo/MElementOctree.h Geo/MPoint.h Geo/MLine.h Geo/MTriangle.h Geo/MFace.h Geo/MElement.h Geo/MElementOctree.h Geo/MPoint.h Geo/MLine.h
Geo/MQuadrangle.h Geo/MTetrahedron.h Geo/MHexahedron.h Geo/MPrism.h Geo/MTriangle.h Geo/MQuadrangle.h Geo/MTetrahedron.h Geo/MHexahedron.h
Geo/MPyramid.h Geo/MElementCut.h Geo/MElementOctree.h Geo/discreteVertex.h Geo/MPrism.h Geo/MPyramid.h Geo/MElementCut.h Geo/MElementOctree.h
Geo/discreteEdge.h Geo/discreteFace.h Geo/discreteRegion.h Geo/SPoint2.h Geo/SPoint3.h Geo/discreteVertex.h Geo/discreteEdge.h Geo/discreteFace.h Geo/discreteRegion.h
Geo/SVector3.h Geo/STensor3.h Geo/SBoundingBox3d.h Geo/Pair.h Geo/Range.h Geo/SPoint2.h Geo/SPoint3.h Geo/SVector3.h Geo/STensor3.h Geo/SBoundingBox3d.h
Geo/SOrientedBoundingBox.h Geo/CellComplex.h Geo/ChainComplex.h Geo/Cell.h Geo/Pair.h Geo/Range.h Geo/SOrientedBoundingBox.h
Geo/Homology.h Geo/Chain.h Geo/partitionEdge.h Geo/CGNSOptions.h Geo/gmshLevelset.h Geo/CellComplex.h Geo/ChainComplex.h Geo/Cell.h Geo/Homology.h Geo/Chain.h
Mesh/meshGEdge.h Mesh/meshGFace.h Mesh/meshGFaceOptimize.h Mesh/meshGFaceElliptic.h Mesh/meshPartition.h Geo/partitionEdge.h Geo/CGNSOptions.h Geo/gmshLevelset.h
Mesh/meshGFaceDelaunayInsertion.h Mesh/simple3D.h Mesh/meshPartitionOptions.h Mesh/directions3D.h Mesh/yamakawa.h Mesh/meshGEdge.h Mesh/meshGFace.h Mesh/meshGFaceOptimize.h
Mesh/meshGFaceElliptic.h Mesh/meshPartition.h Mesh/meshGFaceDelaunayInsertion.h
Mesh/simple3D.h Mesh/meshPartitionOptions.h Mesh/directions3D.h Mesh/yamakawa.h
Mesh/Voronoi3D.h Mesh/Levy3D.h Mesh/periodical.h Mesh/Voronoi3D.h Mesh/Levy3D.h Mesh/periodical.h
Numeric/mathEvaluator.h Numeric/mathEvaluator.h
Solver/dofManager.h Solver/femTerm.h Solver/laplaceTerm.h Solver/elasticityTerm.h Solver/dofManager.h Solver/femTerm.h Solver/laplaceTerm.h Solver/elasticityTerm.h
...@@ -293,7 +297,7 @@ if(ENABLE_BLAS_LAPACK) ...@@ -293,7 +297,7 @@ if(ENABLE_BLAS_LAPACK)
endif(BLAS_FOUND) endif(BLAS_FOUND)
endif(NOT HAVE_BLAS OR NOT HAVE_LAPACK) endif(NOT HAVE_BLAS OR NOT HAVE_LAPACK)
if(NOT HAVE_BLAS OR NOT HAVE_LAPACK) if(NOT HAVE_BLAS OR NOT HAVE_LAPACK)
message("WARNING: Could not find Blas or Lapack: most meshing algorithms " message(STATUS "Warning: Could not find Blas or Lapack: most meshing algorithms "
"will not be functional") "will not be functional")
endif(NOT HAVE_BLAS OR NOT HAVE_LAPACK) endif(NOT HAVE_BLAS OR NOT HAVE_LAPACK)
endif(ENABLE_BLAS_LAPACK) endif(ENABLE_BLAS_LAPACK)
...@@ -555,8 +559,8 @@ if(HAVE_MESH OR HAVE_SOLVER) ...@@ -555,8 +559,8 @@ if(HAVE_MESH OR HAVE_SOLVER)
add_subdirectory(contrib/Metis) add_subdirectory(contrib/Metis)
include_directories(contrib/Metis) include_directories(contrib/Metis)
set_config_option(HAVE_METIS "Metis") set_config_option(HAVE_METIS "Metis")
message("WARNING: By including Metis you have to comply with Metis' special " message(STATUS "Warning: By including Metis you have to comply with Metis' "
"licensing requirements stated in contrib/Metis/README.txt.") "special licensing requirements stated in contrib/Metis/README.txt.")
endif(ENABLE_METIS) endif(ENABLE_METIS)
if(ENABLE_CHACO) if(ENABLE_CHACO)
...@@ -633,7 +637,7 @@ if(HAVE_MESH) ...@@ -633,7 +637,7 @@ if(HAVE_MESH)
endif(TETGEN_LIB AND TETGEN_INC) endif(TETGEN_LIB AND TETGEN_INC)
endif(ENABLE_TETGEN AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/Tetgen1.5/tetgen.h) endif(ENABLE_TETGEN AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/Tetgen1.5/tetgen.h)
if(HAVE_TETGEN) if(HAVE_TETGEN)
message("WARNING: By including Tetgen you have to comply with Tetgen's " message(STATUS "Warning: By including Tetgen you have to comply with Tetgen's "
"special licensing requirements stated in contrib/Tetgen*/LICENSE.") "special licensing requirements stated in contrib/Tetgen*/LICENSE.")
endif(HAVE_TETGEN) endif(HAVE_TETGEN)
endif(HAVE_MESH) endif(HAVE_MESH)
...@@ -1019,34 +1023,31 @@ foreach(DIR ${GMSH_DIRS}) ...@@ -1019,34 +1023,31 @@ foreach(DIR ${GMSH_DIRS})
source_group(${DIR} REGULAR_EXPRESSION ${DIR}/.*) source_group(${DIR} REGULAR_EXPRESSION ${DIR}/.*)
endforeach(DIR) endforeach(DIR)
# static library target: we don't build it by default (we could then # static library target
# create the gmsh target by linking with it) because doing so slows if(ENABLE_BUILD_LIB)
# down the compile/link development a lot: running ranlib+ar on a add_library(lib STATIC ${GMSH_SRC})
# large static lib every time we recompile is frustratingly set_target_properties(lib PROPERTIES OUTPUT_NAME Gmsh)
# slow. Instead, we build the gmsh target directly from the object if(MSVC)
# files. This is much faster but has one side effect: when we actually set_target_properties(lib PROPERTIES DEBUG_POSTFIX d)
# want to build the lib we need to recompile everything (the first if(ENABLE_MSVC_STATIC_RUNTIME)
# time--it's a separate target) set_target_properties(lib PROPERTIES LINK_FLAGS_RELEASE "/nodefaultlib:LIBCMT")
add_library(lib STATIC EXCLUDE_FROM_ALL ${GMSH_SRC}) endif(ENABLE_MSVC_STATIC_RUNTIME)
set_target_properties(lib PROPERTIES OUTPUT_NAME Gmsh) endif(MSVC)
if(MSVC) endif(ENABLE_BUILD_LIB)
set_target_properties(lib PROPERTIES DEBUG_POSTFIX d)
if(ENABLE_MSVC_STATIC_RUNTIME) # shared library target
set_target_properties(lib PROPERTIES LINK_FLAGS_RELEASE "/nodefaultlib:LIBCMT") if(ENABLE_BUILD_SHARED OR ENABLE_WRAP_PYTHON OR ENABLE_WRAP_JAVA)
endif(ENABLE_MSVC_STATIC_RUNTIME) add_library(shared SHARED ${GMSH_SRC})
endif(MSVC) set_target_properties(shared PROPERTIES OUTPUT_NAME Gmsh)
if(HAVE_LAPACK AND LAPACK_FLAGS)
# shared library target: we don't build it by default either set_target_properties(shared PROPERTIES LINK_FLAGS ${LAPACK_FLAGS})
add_library(shared SHARED EXCLUDE_FROM_ALL ${GMSH_SRC}) endif(HAVE_LAPACK AND LAPACK_FLAGS)
set_target_properties(shared PROPERTIES OUTPUT_NAME Gmsh) if(MSVC AND ENABLE_MSVC_STATIC_RUNTIME)
if(HAVE_LAPACK AND LAPACK_FLAGS) message(STATUS "Warning: By enabling ENABLE_MSVC_STATIC_RUNTIME, shared library "
set_target_properties(shared PROPERTIES LINK_FLAGS ${LAPACK_FLAGS}) "won't link. In MSVC change /MT to /MD in the shared project properties")
endif(HAVE_LAPACK AND LAPACK_FLAGS) endif(MSVC AND ENABLE_MSVC_STATIC_RUNTIME)
if(MSVC AND ENABLE_MSVC_STATIC_RUNTIME) target_link_libraries(shared ${LINK_LIBRARIES})
message("WARNING: By enabling ENABLE_MSVC_STATIC_RUNTIME, shared library wont link. " endif(ENABLE_BUILD_SHARED OR ENABLE_WRAP_PYTHON OR ENABLE_WRAP_JAVA)
"Change in msvc /MT flag to /MD in the shared project properties")
endif(MSVC AND ENABLE_MSVC_STATIC_RUNTIME)
target_link_libraries(shared ${LINK_LIBRARIES})
# binary targets # binary targets
if(HAVE_FLTK) if(HAVE_FLTK)
...@@ -1082,6 +1083,7 @@ elseif(MSVC) ...@@ -1082,6 +1083,7 @@ elseif(MSVC)
set_target_properties(gmsh PROPERTIES LINK_FLAGS "/STACK:16777216") set_target_properties(gmsh PROPERTIES LINK_FLAGS "/STACK:16777216")
endif(WIN32 AND NOT MSVC OR CYGWIN) endif(WIN32 AND NOT MSVC OR CYGWIN)
# parser target
find_program(BISON bison) find_program(BISON bison)
find_program(FLEX flex) find_program(FLEX flex)
if(BISON AND FLEX) if(BISON AND FLEX)
...@@ -1158,7 +1160,9 @@ endif(WIN32 OR CYGWIN) ...@@ -1158,7 +1160,9 @@ endif(WIN32 OR CYGWIN)
# mark targets as optional so we can install them separately if needed # mark targets as optional so we can install them separately if needed
# (e.g. "make lib" or "make shared" followed by "make install/fast") # (e.g. "make lib" or "make shared" followed by "make install/fast")
install(TARGETS gmsh DESTINATION ${GMSH_BIN} OPTIONAL) install(TARGETS gmsh DESTINATION ${GMSH_BIN} OPTIONAL)
install(TARGETS lib shared DESTINATION lib OPTIONAL) if(ENABLE_BUILD_LIB)
install(TARGETS lib shared DESTINATION lib OPTIONAL)
endif(ENABLE_BUILD_LIB)
install(FILES ${GMSH_API} DESTINATION include/gmsh) install(FILES ${GMSH_API} DESTINATION include/gmsh)
install(FILES ${WELCOME_FILE} DESTINATION ${GMSH_DOC} RENAME README.txt) install(FILES ${WELCOME_FILE} DESTINATION ${GMSH_DOC} RENAME README.txt)
install(FILES ${LICENSE_FILE} DESTINATION ${GMSH_DOC}) install(FILES ${LICENSE_FILE} DESTINATION ${GMSH_DOC})
...@@ -1211,7 +1215,7 @@ if(MAKEINFO OR TEXI2PDF) ...@@ -1211,7 +1215,7 @@ if(MAKEINFO OR TEXI2PDF)
add_custom_target(clean_doc COMMAND ${CMAKE_COMMAND} -E remove ${TEX_OBJ}) add_custom_target(clean_doc COMMAND ${CMAKE_COMMAND} -E remove ${TEX_OBJ})
endif(MAKEINFO OR TEXI2PDF) endif(MAKEINFO OR TEXI2PDF)
if(APPLE) if(APPLE AND ENABLE_BUILD_LIB)
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/utils/misc/gmsh_framework.plist F0) file(READ ${CMAKE_CURRENT_SOURCE_DIR}/utils/misc/gmsh_framework.plist F0)
string(REPLACE GMSH_VERSION "${GMSH_VERSION}" F1 "${F0}") string(REPLACE GMSH_VERSION "${GMSH_VERSION}" F1 "${F0}")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/Info_framework.plist "${F1}") file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/Info_framework.plist "${F1}")
...@@ -1236,7 +1240,7 @@ if(APPLE) ...@@ -1236,7 +1240,7 @@ if(APPLE)
${FILE} ${CMAKE_CURRENT_BINARY_DIR}/Gmsh.framework/Versions/A/Headers/ ${FILE} ${CMAKE_CURRENT_BINARY_DIR}/Gmsh.framework/Versions/A/Headers/
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endforeach(FILE) endforeach(FILE)
endif(APPLE) endif(APPLE AND ENABLE_BUILD_LIB)
set(CPACK_PACKAGE_VENDOR "Christophe Geuzaine and Jean-Francois Remacle") set(CPACK_PACKAGE_VENDOR "Christophe Geuzaine and Jean-Francois Remacle")
set(CPACK_PACKAGE_VERSION_MAJOR ${GMSH_MAJOR_VERSION}) set(CPACK_PACKAGE_VERSION_MAJOR ${GMSH_MAJOR_VERSION})
...@@ -1297,7 +1301,7 @@ if(ENABLE_WRAP_PYTHON) ...@@ -1297,7 +1301,7 @@ if(ENABLE_WRAP_PYTHON)
message(STATUS "Found SWIG version " ${SWIG_VERSION}) message(STATUS "Found SWIG version " ${SWIG_VERSION})
string(SUBSTRING ${SWIG_VERSION} 0 1 SWIG_MAJOR_VERSION) string(SUBSTRING ${SWIG_VERSION} 0 1 SWIG_MAJOR_VERSION)
if(SWIG_MAJOR_VERSION EQUAL 1) if(SWIG_MAJOR_VERSION EQUAL 1)
message("WARNING: Python bindings require SWIG >= 2: disabling Python") message(WARNING "Python bindings require SWIG >= 2: disabling Python")
else(SWIG_MAJOR_VERSION EQUAL 1) else(SWIG_MAJOR_VERSION EQUAL 1)
add_subdirectory(wrappers/gmshpy) add_subdirectory(wrappers/gmshpy)
endif(SWIG_MAJOR_VERSION EQUAL 1) endif(SWIG_MAJOR_VERSION EQUAL 1)
...@@ -1306,29 +1310,34 @@ endif(ENABLE_WRAP_PYTHON) ...@@ -1306,29 +1310,34 @@ endif(ENABLE_WRAP_PYTHON)
if(ENABLE_WRAP_JAVA) if(ENABLE_WRAP_JAVA)
if(NOT HAVE_BLAS OR NOT HAVE_LAPACK) if(NOT HAVE_BLAS OR NOT HAVE_LAPACK)
message("WARNING: Java wrapping samples will not work without BLAS and LAPACK") message(WARNING "Java wrapping samples will not work without BLAS and LAPACK")
endif(NOT HAVE_BLAS OR NOT HAVE_LAPACK) endif(NOT HAVE_BLAS OR NOT HAVE_LAPACK)
add_subdirectory(wrappers/java) add_subdirectory(wrappers/java)
endif(ENABLE_WRAP_JAVA) endif(ENABLE_WRAP_JAVA)
include(CPack) include(CPack)
message("") include(CTest)
message("Gmsh ${GMSH_VERSION} has been configured for ${GMSH_OS} with the " # we will need some common testing framwork to make actual tests
"following options:" ${GMSH_CONFIG_OPTIONS}) file(GLOB_RECURSE TESTFILES tutorial/x*.geo)
message("") foreach(TESTFILE ${TESTFILES})
message("C compiler: " ${CMAKE_C_COMPILER}) add_test(${TESTFILE} gmsh ${TESTFILE})
message("C++ compiler: " ${CMAKE_CXX_COMPILER}) endforeach()
if(NOT CMAKE_BUILD_TYPE)
message("C compiler flags: " ${CMAKE_C_FLAGS}) message(STATUS "")
message("C++ compiler flags: " ${CMAKE_CXX_FLAGS}) message(STATUS "Gmsh ${GMSH_VERSION} has been configured for ${GMSH_OS}")
else(NOT CMAKE_BUILD_TYPE) message(STATUS "")
message("Build type: " ${CMAKE_BUILD_TYPE}) message(STATUS " * Build options:" ${GMSH_CONFIG_OPTIONS})
endif(NOT CMAKE_BUILD_TYPE) message(STATUS " * Build type: " ${CMAKE_BUILD_TYPE})
message("Install prefix: " ${CMAKE_INSTALL_PREFIX}) message(STATUS " * C compiler: " ${CMAKE_C_COMPILER})
message("") message(STATUS " * C++ compiler: " ${CMAKE_CXX_COMPILER})
message("Run 'ccmake ${CMAKE_CURRENT_SOURCE_DIR}' to fine-tune the configuration.") if(ENV_PETSC_ARCH)
message("") message(STATUS " * PETSc arch: " ${ENV_PETSC_ARCH})
endif(ENV_PETSC_ARCH)
message(STATUS " * Install prefix: " ${CMAKE_INSTALL_PREFIX})
message(STATUS "")
message(STATUS "Run 'ccmake ${CMAKE_CURRENT_SOURCE_DIR}' to fine-tune the configuration.")
message(STATUS "")
mark_as_advanced(BISON FLEX GMP_LIB GMSH_EXTRA_VERSION HDF5_LIB MAKEINFO mark_as_advanced(BISON FLEX GMP_LIB GMSH_EXTRA_VERSION HDF5_LIB MAKEINFO
MED_LIB OCC_INC CGNS_INC SZ_LIB TAUCS_LIB ACIS_LIB TEXI2PDF) MED_LIB OCC_INC CGNS_INC SZ_LIB TAUCS_LIB ACIS_LIB TEXI2PDF)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment