2020## use this copy of the mmg distribution only if you accept them.
2121## =============================================================================
2222
23- CMAKE_MINIMUM_REQUIRED (VERSION 2.8.0 )
23+ CMAKE_MINIMUM_REQUIRED (VERSION 2.8.12 )
2424
2525# if PROJECT_NAME is defined, mmg is a subproject
2626if (DEFINED PROJECT_NAME )
@@ -190,6 +190,13 @@ IF ( BUILD_MMG3D OR BUILD_MMGS )
190190ELSE ()
191191 SET (BUILD_MMGS3D OFF )
192192ENDIF ()
193+
194+ # Explicitly set the DNDEBUG flag in case the user or a parent project overrides
195+ # it.
196+ if (NOT CMAKE_BUILD_TYPE MATCHES Debug)
197+ add_definitions (-DNDEBUG)
198+ endif ()
199+
193200############################################################################
194201#####
195202##### Fortran header: libmmgtypesf.h
@@ -311,6 +318,9 @@ ENDFUNCTION()
311318
312319OPTION (BUILD_SHARED_LIBS "Build shared libraries" OFF )
313320INVERT_BOOL("BUILD_STATIC_LIBS" ${BUILD_SHARED_LIBS} )
321+ IF ( (${BUILD_STATIC_LIBS} EQUAL ON ) AND NOT CMAKE_POSITION_INDEPENDENT_CODE )
322+ SET (CMAKE_POSITION_INDEPENDENT_CODE ON )
323+ ENDIF ()
314324
315325#------------------------------- mmg2d
316326CMAKE_DEPENDENT_OPTION ( LIBMMG2D_STATIC "Compile the mmg2d static library" ${BUILD_STATIC_LIBS}
@@ -425,6 +435,17 @@ CMAKE_DEPENDENT_OPTION(
425435###############################################################################
426436SET (LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR} /lib)
427437
438+ # CTEST_OUTPUT_DIR MUST BE SETTED HERE TO AVOID UNINITIALIZATION FOR LIBRARY
439+ # TESTS DEFS
440+ OPTION ( BUILD_TESTING "Enable/Disable continuous integration" OFF )
441+
442+ IF ( BUILD_TESTING )
443+ SET ( CTEST_OUTPUT_DIR ${PROJECT_BINARY_DIR} /TEST_OUTPUTS
444+ CACHE PATH "Path toward the tests outputs" )
445+ MARK_AS_ADVANCED ( CTEST_OUTPUT_DIR )
446+ FILE ( MAKE_DIRECTORY ${CTEST_OUTPUT_DIR} )
447+ ENDIF ( )
448+
428449IF ( BUILD_MMG2D )
429450 INCLUDE (cmake/modules/mmg2d.cmake)
430451ENDIF ( )
@@ -443,7 +464,7 @@ ENDIF ( )
443464
444465IF ( SCOTCH_FOUND )
445466 # Include Scotch Dir here to ensure that Mmg doesn't search it's own headers in /usr/local
446- INCLUDE_DIRECTORIES (PUBLIC ${SCOTCH_INCLUDE_DIRS} )
467+ INCLUDE_DIRECTORIES (${SCOTCH_INCLUDE_DIRS} )
447468ENDIF ()
448469
449470IF ( MmgTargetsExported )
@@ -473,8 +494,6 @@ ENDIF()
473494#####
474495###############################################################################
475496
476- OPTION ( BUILD_TESTING "Enable/Disable continuous integration" OFF )
477-
478497CMAKE_DEPENDENT_OPTION (
479498 ONLY_VERY_SHORT_TESTS "Enable/Disable very short tests" OFF
480499 "BUILD_TESTING;NOT LONG_TESTS" OFF )
@@ -490,18 +509,12 @@ CMAKE_DEPENDENT_OPTION ( COVERAGE "Watch code coverage (Linux only)" OFF
490509
491510IF ( BUILD_TESTING )
492511
493- SET ( CTEST_OUTPUT_DIR ${PROJECT_BINARY_DIR} /TEST_OUTPUTS
494- CACHE PATH "Path toward the tests outputs" )
495- MARK_AS_ADVANCED ( CTEST_OUTPUT_DIR )
496-
497- FILE ( MAKE_DIRECTORY ${CTEST_OUTPUT_DIR} )
498-
499512 IF ( NOT ONLY_VERY_SHORT_TESTS )
500513 ##-------------------------------------------------------------------##
501514 ##------- Get the continuous integration tests ----------------------##
502515 ##-------------------------------------------------------------------##
503516 INCLUDE (cmake/modules/LoadCiTests.cmake)
504- ENDIF ( )
517+ ENDIF ( )
505518
506519 ##-------------------------------------------------------------------##
507520 ##------- Set the continuous integration options --------------------##
@@ -555,18 +568,22 @@ ENDIF ( )
555568 SET (LISTEXEC_MMG ${LISTEXEC_MMGS} ${LISTEXEC_MMG3D} )
556569 SET (EXECUT_MMG ${EXECUT_MMGS} ${EXECUT_MMG3D} )
557570
558- # Change authorisations for some files...
559- IF ( EXISTS ${CTEST_OUTPUT_DIR} /LeakCheck_AbnormalEnd7/unreadable.meshb)
560- FILE (REMOVE ${CTEST_OUTPUT_DIR} /LeakCheck_AbnormalEnd7/unwrittable.meshb)
571+ # Make some files not openable
572+ IF ( EXISTS ${CTEST_OUTPUT_DIR} /unwrittable7.meshb
573+ AND NOT IS_DIRECTORY ${CTEST_OUTPUT_DIR} /unwrittable7.meshb )
574+ FILE ( REMOVE ${CTEST_OUTPUT_DIR} /unwrittable7.meshb )
575+ ENDIF ()
576+ IF ( NOT EXISTS ${CTEST_OUTPUT_DIR} /unwrittable7.meshb)
577+ FILE (MAKE_DIRECTORY ${CTEST_OUTPUT_DIR} /unwrittable7.meshb)
561578 ENDIF ()
562- FILE (COPY ${MMG_CI_TESTS} /LeakCheck_AbnormalEnd7/dout.mesh
563- DESTINATION ${CTEST_OUTPUT_DIR} /AbnormalEnd7/unwrittable.meshb)
564579
565- IF ( EXISTS ${CTEST_OUTPUT_DIR} /LeakCheck_AbnormalEnd8/unwrittable.sol)
566- FILE (REMOVE ${CTEST_OUTPUT_DIR} /LeakCheck_AbnormalEnd8/unwrittable.sol)
580+ IF ( EXISTS ${CTEST_OUTPUT_DIR} /unwrittable8.sol
581+ AND NOT IS_DIRECTORY ${CTEST_OUTPUT_DIR} /unwrittable8.sol )
582+ FILE ( REMOVE ${CTEST_OUTPUT_DIR} /unwrittable8.sol )
583+ ENDIF ()
584+ IF ( NOT EXISTS ${CTEST_OUTPUT_DIR} /unwrittable8.sol)
585+ FILE (MAKE_DIRECTORY ${CTEST_OUTPUT_DIR} /unwrittable8.sol)
567586 ENDIF ()
568- FILE (COPY ${MMG_CI_TESTS} /LeakCheck_AbnormalEnd8/dsol.sol
569- DESTINATION ${CTEST_OUTPUT_DIR} /AbnormalEnd8/unwrittable.sol)
570587
571588 # Add common tests for mmgs/3d appli
572589 INCLUDE ( ${PROJECT_SOURCE_DIR} /cmake/testing/mmg_tests.cmake )
0 commit comments