Skip to content

Commit 4b6f4bd

Browse files
authored
Merge pull request #413 from iqtree/Alisim_mpi
Fix compilation errors after updating cmake_minimum_required (from 3.0) to 3.5
2 parents 516d8d9 + a63f56a commit 4b6f4bd

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

CMakeLists.txt

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,22 @@ if(Boost_FOUND)
9797
add_definitions(-DUSE_BOOST)
9898
endif()
9999

100+
# NOTE: After updating cmake_minimum_required to 3.5,
101+
# if we call check_function_exists() after set(CMAKE_EXE_LINKER_FLAGS), it returns function not found
102+
# So, I moved this step upward to avoid the compilation errors due to not-found functions
103+
##################################################################
104+
# check existence of a few basic functions
105+
##################################################################
106+
include (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake)
107+
check_function_exists (gettimeofday HAVE_GETTIMEOFDAY)
108+
check_function_exists (getrusage HAVE_GETRUSAGE)
109+
check_function_exists (GlobalMemoryStatusEx HAVE_GLOBALMEMORYSTATUSEX)
110+
check_function_exists (strndup HAVE_STRNDUP)
111+
check_function_exists (strtok_r HAVE_STRTOK_R)
112+
include (CheckIncludeFile)
113+
CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTDH)
114+
find_package(Backtrace)
115+
100116
# The version number.
101117
set (iqtree_VERSION_MAJOR 2)
102118
set (iqtree_VERSION_MINOR 4)
@@ -672,19 +688,6 @@ elseif (CLANG AND NOT CLANG_UNDER_VS)
672688
set(CMAKE_C_FLAGS_MEM "-g -O1")
673689
endif()
674690

675-
##################################################################
676-
# check existence of a few basic functions
677-
##################################################################
678-
include (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake)
679-
check_function_exists (gettimeofday HAVE_GETTIMEOFDAY)
680-
check_function_exists (getrusage HAVE_GETRUSAGE)
681-
check_function_exists (GlobalMemoryStatusEx HAVE_GLOBALMEMORYSTATUSEX)
682-
check_function_exists (strndup HAVE_STRNDUP)
683-
check_function_exists (strtok_r HAVE_STRTOK_R)
684-
include (CheckIncludeFile)
685-
CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTDH)
686-
find_package(Backtrace)
687-
688691
# configure a header file to pass some of the CMake settings
689692
# to the source code
690693
configure_file (

cmaple

0 commit comments

Comments
 (0)