@@ -97,6 +97,22 @@ if(Boost_FOUND)
9797 add_definitions (-DUSE_BOOST )
9898endif ()
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.
101117set (iqtree_VERSION_MAJOR 2)
102118set (iqtree_VERSION_MINOR 4)
@@ -672,19 +688,6 @@ elseif (CLANG AND NOT CLANG_UNDER_VS)
672688 set (CMAKE_C_FLAGS_MEM "-g -O1" )
673689endif ()
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
690693configure_file (
0 commit comments