Skip to content

Commit

Permalink
Merge pull request #284 from MmgTools/feature/cmake-3.5
Browse files Browse the repository at this point in the history
Remove compatibility with old cmake (<3.5).
  • Loading branch information
coprigent authored Oct 1, 2024
2 parents 8a84488 + 4267b33 commit 7efe346
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 75 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
## use this copy of the mmg distribution only if you accept them.
## =============================================================================

CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
CMAKE_MINIMUM_REQUIRED(VERSION 3.5)

# if PROJECT_NAME is defined, mmg is a subproject
if(DEFINED PROJECT_NAME)
Expand Down
57 changes: 16 additions & 41 deletions cmake/modules/macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -147,29 +147,19 @@ MACRO ( ADD_AND_INSTALL_LIBRARY
ENDIF()
ADD_DEPENDENCIES( ${target_name} ${target_dependencies})

IF ( CMAKE_VERSION VERSION_LESS 2.8.12 )
INCLUDE_DIRECTORIES ( BEFORE
${MMGCOMMON_BINARY_DIR} ${MMGCOMMON_SOURCE_DIR} ${PROJECT_BINARY_DIR}/include ${PROJECT_BINARY_DIR})
ELSE ( )
target_include_directories( ${target_name} BEFORE PUBLIC
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include/>
$<BUILD_INTERFACE:${MMGCOMMON_SOURCE_DIR}>
$<BUILD_INTERFACE:${MMGCOMMON_BINARY_DIR}>
$<BUILD_INTERFACE:${MMG3D_SOURCE_DIR}>
$<BUILD_INTERFACE:${MMGS_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

ENDIF ( )
target_include_directories( ${target_name} BEFORE PUBLIC
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include/>
$<BUILD_INTERFACE:${MMGCOMMON_SOURCE_DIR}>
$<BUILD_INTERFACE:${MMGCOMMON_BINARY_DIR}>
$<BUILD_INTERFACE:${MMG3D_SOURCE_DIR}>
$<BUILD_INTERFACE:${MMGS_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

if ( SCOTCH_FOUND AND NOT USE_SCOTCH MATCHES OFF )
message(STATUS "[mmg] add include scotch directories ${SCOTCH_INCLUDE_DIRS}")
IF ( CMAKE_VERSION VERSION_LESS 2.8.12 )
INCLUDE_DIRECTORIES ( AFTER ${SCOTCH_INCLUDE_DIRS} )
ELSE ( )
target_include_directories( ${target_name} PUBLIC ${SCOTCH_INCLUDE_DIRS} )
endif()
endif( )
target_include_directories( ${target_name} PUBLIC ${SCOTCH_INCLUDE_DIRS} )
endif()

SET_TARGET_PROPERTIES ( ${target_name} PROPERTIES
OUTPUT_NAME ${output_name}
Expand Down Expand Up @@ -236,22 +226,11 @@ MACRO ( ADD_AND_INSTALL_EXECUTABLE
my_add_link_flags ( ${exec_name} "/SAFESEH:NO")
ENDIF ( )

IF ( CMAKE_VERSION VERSION_LESS 2.8.12 )
INCLUDE_DIRECTORIES ( BEFORE
${MMGCOMMON_BINARY_DIR} ${MMGCOMMON_SOURCE_DIR} ${PROJECT_BINARY_DIR}/include ${PROJECT_BINARY_DIR} )
if ( SCOTCH_FOUND AND NOT USE_SCOTCH MATCHES OFF )
message(STATUS "[mmg] add include scotch directories ${SCOTCH_INCLUDE_DIRS}")
INCLUDE_DIRECTORIES ( AFTER ${SCOTCH_INCLUDE_DIRS} )
ENDIF()

ELSE ( )
TARGET_INCLUDE_DIRECTORIES ( ${exec_name} BEFORE PUBLIC
${MMGCOMMON_BINARY_DIR} ${MMGCOMMON_SOURCE_DIR} ${PROJECT_BINARY_DIR}/include ${PROJECT_BINARY_DIR} )
if ( SCOTCH_FOUND AND NOT USE_SCOTCH MATCHES OFF )
message(STATUS "[mmg] add include scotch directories ${SCOTCH_INCLUDE_DIRS}")
target_include_directories( ${exec_name} BEFORE PUBLIC ${SCOTCH_INCLUDE_DIRS} )
ENDIF()

TARGET_INCLUDE_DIRECTORIES ( ${exec_name} BEFORE PUBLIC
${MMGCOMMON_BINARY_DIR} ${MMGCOMMON_SOURCE_DIR} ${PROJECT_BINARY_DIR}/include ${PROJECT_BINARY_DIR} )
if ( SCOTCH_FOUND AND NOT USE_SCOTCH MATCHES OFF )
message(STATUS "[mmg] add include scotch directories ${SCOTCH_INCLUDE_DIRS}")
target_include_directories( ${exec_name} BEFORE PUBLIC ${SCOTCH_INCLUDE_DIRS} )
ENDIF ( )

TARGET_LINK_LIBRARIES ( ${exec_name} PRIVATE ${LIBRARIES} )
Expand Down Expand Up @@ -295,11 +274,7 @@ MACRO ( ADD_LIBRARY_TEST target_name main_path target_dependency lib_name lib_ty
ADD_EXECUTABLE ( ${target_name} ${main_path} )
ADD_DEPENDENCIES( ${target_name} ${target_dependency} )

IF ( CMAKE_VERSION VERSION_LESS 2.8.12 )
INCLUDE_DIRECTORIES ( BEFORE ${PROJECT_BINARY_DIR}/include )
ELSE ( )
TARGET_INCLUDE_DIRECTORIES ( ${target_name} BEFORE PUBLIC ${PROJECT_BINARY_DIR}/include )
ENDIF ( )
TARGET_INCLUDE_DIRECTORIES ( ${target_name} BEFORE PUBLIC ${PROJECT_BINARY_DIR}/include )

IF ( WIN32 AND ((NOT MINGW) AND SCOTCH_FOUND AND NOT USE_SCOTCH MATCHES OFF) )
MY_ADD_LINK_FLAGS ( ${target_name} "/SAFESEH:NO" )
Expand Down
44 changes: 11 additions & 33 deletions cmake/testing/mmg_tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -450,41 +450,19 @@ IF ( NOT WIN32 )
ADD_DEPENDENCIES ( mmg_get_tagname copy_mmgcommon_headers
copy_3d_headers copy_2d_headers copy_s_headers )

TARGET_INCLUDE_DIRECTORIES ( mmg_get_tagname BEFORE PUBLIC
${MMGCOMMON_SOURCE_DIR} ${PROJECT_BINARY_DIR}/include
${PROJECT_BINARY_DIR}/src/common
)
if ( SCOTCH_FOUND AND NOT USE_SCOTCH MATCHES OFF )
target_include_directories( mmg_get_tagname BEFORE PUBLIC ${SCOTCH_INCLUDE_DIRS} )
ENDIF ( )

IF ( CMAKE_VERSION VERSION_LESS 2.8.12 )
INCLUDE_DIRECTORIES ( BEFORE
${MMGCOMMON_SOURCE_DIR} ${PROJECT_BINARY_DIR}/include
${PROJECT_BINARY_DIR}/src/common )
if ( SCOTCH_FOUND AND NOT USE_SCOTCH MATCHES OFF )
INCLUDE_DIRECTORIES ( AFTER ${SCOTCH_INCLUDE_DIRS} )
ENDIF()

SET( GET_TAGNAME_LIBRARIES ${LIBRARIES} )

IF( ELAS_FOUND AND NOT USE_ELAS MATCHES OFF )
# Set flags for building test program
INCLUDE_DIRECTORIES(AFTER ${ELAS_INCLUDE_DIR})
SET( GET_TAGNAME_LIBRARIES ${ELAS_LINK_FLAGS} ${ELAS_LIBRARY} ${GET_TAGNAME_LIBRARIES} )

ENDIF ( )


ELSE ( )
TARGET_INCLUDE_DIRECTORIES ( mmg_get_tagname BEFORE PUBLIC
${MMGCOMMON_SOURCE_DIR} ${PROJECT_BINARY_DIR}/include
${PROJECT_BINARY_DIR}/src/common
)
if ( SCOTCH_FOUND AND NOT USE_SCOTCH MATCHES OFF )
target_include_directories( mmg_get_tagname BEFORE PUBLIC ${SCOTCH_INCLUDE_DIRS} )
ENDIF ( )

SET( GET_TAGNAME_LIBRARIES ${LIBRARIES} )

IF( ELAS_FOUND AND NOT USE_ELAS MATCHES OFF )
target_include_directories( mmg_get_tagname AFTER PUBLIC ${ELAS_INCLUDE_DIR} )
SET( GET_TAGNAME_LIBRARIES ${ELAS_LINK_FLAGS} ${ELAS_LIBRARY} ${GET_TAGNAME_LIBRARIES})
ENDIF ( )
SET( GET_TAGNAME_LIBRARIES ${LIBRARIES} )

IF( ELAS_FOUND AND NOT USE_ELAS MATCHES OFF )
target_include_directories( mmg_get_tagname AFTER PUBLIC ${ELAS_INCLUDE_DIR} )
SET( GET_TAGNAME_LIBRARIES ${ELAS_LINK_FLAGS} ${ELAS_LIBRARY} ${GET_TAGNAME_LIBRARIES})
ENDIF ( )

TARGET_LINK_LIBRARIES ( mmg_get_tagname PRIVATE ${GET_TAGNAME_LIBRARIES} )
Expand Down

0 comments on commit 7efe346

Please sign in to comment.