X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/70439fdf4efc3ac256a832dcad7b3ce04c35be23..40a6b57b33ba92df9a10600b8d6fa10fff80c9d2:/buildtools/Cmake/CompleteInFiles.cmake diff --git a/buildtools/Cmake/CompleteInFiles.cmake b/buildtools/Cmake/CompleteInFiles.cmake index f7804dcc4a..837caf059f 100644 --- a/buildtools/Cmake/CompleteInFiles.cmake +++ b/buildtools/Cmake/CompleteInFiles.cmake @@ -75,10 +75,6 @@ TEST_BIG_ENDIAN(BIGENDIAN) include(FindGraphviz) include(FindLibSigc++) -set(HAVE_GTNETS 0) -if(enable_gtnets) - include(FindGTnets) -endif() if(enable_java) find_package(Java REQUIRED COMPONENTS Runtime Development) find_package(JNI REQUIRED) @@ -99,31 +95,51 @@ endif() if(enable_lua) include(FindLua51Simgrid) endif() + set(HAVE_NS3 0) if(enable_ns3) include(FindNS3) + if (NOT HAVE_NS3) + message(FATAL_ERROR "Cannot find NS3. Please install it (apt-get install ns3 libns3-dev) or disable that cmake option") + endif() endif() -# algorithm 1.50.0 -# function 1.23.0 -# intrusive 1.35.0 -# lambda 1.28.0 -# signals2 1.39.0 -find_package(Boost 1.42 REQUIRED) +find_package(Boost 1.48) if(Boost_FOUND) include_directories(${Boost_INCLUDE_DIRS}) else() - if(APPLE) #MAC - message(FATAL_ERROR, "Failed to find Boost libraries (Try to install them with 'sudo fink install boost1.53.nopython')") + if(APPLE) + message(FATAL_ERROR "Failed to find Boost libraries (Try to install them with 'sudo fink install boost1.53.nopython')") else() - message(FATAL_ERROR, "Failed to find Boost libraries") + message(FATAL_ERROR "Failed to find Boost libraries." + "Did you install libboost-dev and libboost-context-dev?" + "(libboost-context-dev is optional)") endif() endif() +# Try again to see if we have libboost-context +find_package(Boost 1.42 COMPONENTS context) +set(Boost_FOUND 1) # We don't care of whether this component is missing + +if(Boost_FOUND AND Boost_CONTEXT_FOUND) + # We should use feature detection for this instead: + if (Boost_VERSION LESS 105600) + message("Found Boost.Context API v1") + set(HAVE_BOOST_CONTEXT 1) + else() + message("Found Boost.Context API v2") + set(HAVE_BOOST_CONTEXT 2) + endif() +else() + message (" boost : found.") + message (" boost-context: missing. Install libboost-context-dev for this optional feature.") + set(HAVE_BOOST_CONTEXT 0) +endif() + # Checks for header libraries functions. CHECK_LIBRARY_EXISTS(dl dlopen "" HAVE_DLOPEN_IN_LIBDL) CHECK_LIBRARY_EXISTS(execinfo backtrace "" HAVE_BACKTRACE_IN_LIBEXECINFO) -CHECK_LIBRARY_EXISTS(pthread pthread_create "" pthread) +CHECK_LIBRARY_EXISTS(pthread pthread_create "" HAVE_PTHREAD) CHECK_LIBRARY_EXISTS(pthread sem_init "" HAVE_SEM_INIT_LIB) CHECK_LIBRARY_EXISTS(pthread sem_open "" HAVE_SEM_OPEN_LIB) CHECK_LIBRARY_EXISTS(pthread sem_timedwait "" HAVE_SEM_TIMEDWAIT_LIB) @@ -131,7 +147,7 @@ CHECK_LIBRARY_EXISTS(pthread pthread_mutex_timedlock "" HAVE_MUTEX_TIMEDLOCK_LIB CHECK_LIBRARY_EXISTS(rt clock_gettime "" HAVE_POSIX_GETTIME) if(CMAKE_SYSTEM_NAME MATCHES "Darwin") - set(CMAKE_REQUIRED_DEFINITIONS "-D_XOPEN_SOURCE") + set(CMAKE_REQUIRED_DEFINITIONS "-D_XOPEN_SOURCE=700 -D_DARWIN_C_SOURCE") endif() CHECK_INCLUDE_FILES("time.h;sys/time.h" TIME_WITH_SYS_TIME) @@ -145,7 +161,7 @@ CHECK_INCLUDE_FILE("sys/stat.h" HAVE_SYS_STAT_H) CHECK_INCLUDE_FILE("windows.h" HAVE_WINDOWS_H) CHECK_INCLUDE_FILE("winsock.h" HAVE_WINSOCK_H) CHECK_INCLUDE_FILE("winsock2.h" HAVE_WINSOCK2_H) -CHECK_INCLUDE_FILE("WinDef.h" HAVE_WINDEF_H) +CHECK_INCLUDE_FILE("windef.h" HAVE_WINDEF_H) CHECK_INCLUDE_FILE("errno.h" HAVE_ERRNO_H) CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H) CHECK_INCLUDE_FILE("execinfo.h" HAVE_EXECINFO_H) @@ -177,6 +193,8 @@ CHECK_FUNCTION_EXISTS(vasprintf HAVE_VASPRINTF) CHECK_FUNCTION_EXISTS(makecontext HAVE_MAKECONTEXT) CHECK_FUNCTION_EXISTS(mmap HAVE_MMAP) CHECK_FUNCTION_EXISTS(process_vm_readv HAVE_PROCESS_VM_READV) +CHECK_FUNCTION_EXISTS(strdup SIMGRID_HAVE_STRDUP) +CHECK_FUNCTION_EXISTS(_strdup SIMGRID_HAVE__STRDUP) #Check if __thread is defined execute_process( @@ -203,6 +221,7 @@ else() SET(HAVE_MMALLOC 0) endif() + if(WIN32) #THOSE FILES ARE FUNCTIONS ARE NOT DETECTED BUT THEY SHOULD... set(HAVE_UCONTEXT_H 1) set(HAVE_MAKECONTEXT 1) @@ -220,13 +239,7 @@ endif() if(enable_latency_bound_tracking) SET(HAVE_LATENCY_BOUND_TRACKING 1) else() - if(enable_gtnets) - message(STATUS "Warning : Turning latency_bound_tracking to ON because GTNeTs is ON") - SET(enable_latency_bound_tracking ON) - SET(HAVE_LATENCY_BOUND_TRACKING 1) - else() - SET(HAVE_LATENCY_BOUND_TRACKING 0) - endif() + SET(HAVE_LATENCY_BOUND_TRACKING 0) endif() if(enable_mallocators) @@ -251,7 +264,15 @@ endif() if(enable_smpi) include(FindGFortran) + #really checks for objdump for privatization + find_package(BinUtils QUIET) SET(HAVE_SMPI 1) + + if( NOT "${CMAKE_OBJDUMP}" MATCHES "CMAKE_OBJDUMP-NOTFOUND" AND HAVE_MMAP) + SET(HAVE_PRIVATIZATION 1) + else() + SET(HAVE_PRIVATIZATION 0) + endif() endif() #-------------------------------------------------------------------------------------------------- @@ -299,13 +320,13 @@ endif() #-------------------------------------------------------------------------------------------------- ### Initialize of CONTEXT THREADS -if(pthread) +if(HAVE_PTHREAD) set(pthread 1) elseif(pthread) set(pthread 0) endif() -if(pthread) +if(HAVE_PTHREAD) ### Test that we have a way to create semaphores if(HAVE_SEM_OPEN_LIB) @@ -314,6 +335,7 @@ if(pthread) OUTPUT_VARIABLE HAVE_SEM_OPEN_compil ) + # Test sem_open by compiling: if(HAVE_SEM_OPEN_compil) set(HAVE_SEM_OPEN 0) message(STATUS "Warning: sem_open not compilable") @@ -323,27 +345,29 @@ if(pthread) message(STATUS "sem_open is compilable") endif() - execute_process(COMMAND ./sem_open - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - RESULT_VARIABLE HAVE_SEM_OPEN_run - OUTPUT_VARIABLE var_compil - ) - file(REMOVE sem_open) - - if(NOT HAVE_SEM_OPEN_run) - set(HAVE_SEM_OPEN 1) - message(STATUS "sem_open is executable") - else() - set(HAVE_SEM_OPEN 0) - if(EXISTS "${CMAKE_BINARY_DIR}/sem_open") - message(STATUS "Bin ${CMAKE_BINARY_DIR}/sem_open exists!") + # If we're not crosscompiling, we check by executing the program: + if (HAVE_SEM_OPEN AND NOT CMAKE_CROSSCOMPILING) + execute_process(COMMAND ./sem_open + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + RESULT_VARIABLE HAVE_SEM_OPEN_run + OUTPUT_VARIABLE var_compil + ) + if (NOT HAVE_SEM_OPEN_run) + set(HAVE_SEM_OPEN 1) + message(STATUS "sem_open is executable") else() - message(STATUS "Bin ${CMAKE_BINARY_DIR}/sem_open not exists!") + set(HAVE_SEM_OPEN 0) + if(EXISTS "${CMAKE_BINARY_DIR}/sem_open") + message(STATUS "Bin ${CMAKE_BINARY_DIR}/sem_open exists!") + else() + message(STATUS "Bin ${CMAKE_BINARY_DIR}/sem_open not exists!") + endif() + message(STATUS "Warning: sem_open not executable") + message(STATUS "Compilation output: '${var_compil}'") + message(STATUS "Exit result of sem_open: ${HAVE_SEM_OPEN_run}") endif() - message(STATUS "Warning: sem_open not executable") - message(STATUS "Compilation output: '${var_compil}'") - message(STATUS "Exit result of sem_open: ${HAVE_SEM_OPEN_run}") endif() + file(REMOVE sem_open) else() set(HAVE_SEM_OPEN 0) @@ -354,6 +378,7 @@ if(pthread) WORKING_DIRECTORY ${CMAKE_BINARY_DIR} RESULT_VARIABLE HAVE_SEM_INIT_run OUTPUT_VARIABLE HAVE_SEM_INIT_compil) + # Test sem_init by compiling: if(HAVE_SEM_INIT_compil) set(HAVE_SEM_INIT 0) message(STATUS "Warning: sem_init not compilable") @@ -362,28 +387,30 @@ if(pthread) set(HAVE_SEM_INIT 1) message(STATUS "sem_init is compilable") endif() - execute_process(COMMAND ./sem_init - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - RESULT_VARIABLE HAVE_SEM_INIT_run - OUTPUT_VARIABLE var_compil - ) - file(REMOVE sem_init) - - if(NOT HAVE_SEM_INIT_run) - set(HAVE_SEM_INIT 1) - message(STATUS "sem_init is executable") - else() - set(HAVE_SEM_INIT 0) - if(EXISTS "${CMAKE_BINARY_DIR}/sem_init") - message(STATUS "Bin ${CMAKE_BINARY_DIR}/sem_init exists!") + # If we're not crosscompiling, we check by executing the program: + if (HAVE_SEM_INIT AND NOT CMAKE_CROSSCOMPILING) + execute_process(COMMAND ./sem_init + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + RESULT_VARIABLE HAVE_SEM_INIT_run + OUTPUT_VARIABLE var_compil + ) + if (NOT HAVE_SEM_INIT_run) + set(HAVE_SEM_INIT 1) + message(STATUS "sem_init is executable") else() - message(STATUS "Bin ${CMAKE_BINARY_DIR}/sem_init not exists!") + set(HAVE_SEM_INIT 0) + if(EXISTS "${CMAKE_BINARY_DIR}/sem_init") + message(STATUS "Bin ${CMAKE_BINARY_DIR}/sem_init exists!") + else() + message(STATUS "Bin ${CMAKE_BINARY_DIR}/sem_init not exists!") + endif() + message(STATUS "Warning: sem_init not executable") + message(STATUS "Compilation output: '${var_compil}'") + message(STATUS "Exit result of sem_init: ${HAVE_SEM_INIT_run}") endif() - message(STATUS "Warning: sem_init not executable") - message(STATUS "Compilation output: '${var_compil}'") - message(STATUS "Exit result of sem_init: ${HAVE_SEM_INIT_run}") endif() + file(REMOVE sem_init) endif() if(NOT HAVE_SEM_OPEN AND NOT HAVE_SEM_INIT) @@ -429,88 +456,38 @@ if(pthread) endif() endif() -# AC_CHECK_MCSC(mcsc=yes, mcsc=no) -set(mcsc_flags "") +# This is needed for ucontext on MacOS X: if(CMAKE_SYSTEM_NAME MATCHES "Darwin") - set(mcsc_flags -D_XOPEN_SOURCE) + add_definitions(-D_XOPEN_SOURCE=700 -D_DARWIN_C_SOURCE) endif() if(WIN32) - if(ARCH_32_BITS) - set(mcsc_flags -D_XBT_WIN32 -D_I_X86_ -I${CMAKE_HOME_DIRECTORY}/src/include -I${CMAKE_HOME_DIRECTORY}/src/xbt) - else() - set(mcsc_flags -D_XBT_WIN32 -D_AMD64_ -I${CMAKE_HOME_DIRECTORY}/src/include -I${CMAKE_HOME_DIRECTORY}/src/xbt) - endif() -endif() - -IF(CMAKE_CROSSCOMPILING) - IF(WIN32) - set(windows_context "yes") - set(IS_WINDOWS 1) - ENDIF() -ELSE() - file(REMOVE "${CMAKE_BINARY_DIR}/testprog*") - file(REMOVE ${CMAKE_BINARY_DIR}/conftestval) - set(MCSC_buildcmd ${CMAKE_C_COMPILER} ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_AC_CHECK_MCSC.c ${mcsc_flags} -o testprog) - execute_process(COMMAND ${MCSC_buildcmd} - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/ - OUTPUT_VARIABLE COMPILE_mcsc_VAR ERROR_VARIABLE COMPILE_mcsc_VAR) - - if(NOT COMPILE_mcsc_VAR) - message(STATUS "prog_AC_CHECK_MCSC.c is compilable") - execute_process(COMMAND ./testprog - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/ - OUTPUT_VARIABLE var_compil) - else() - message(STATUS "prog_AC_CHECK_MCSC.c is not compilable. \nBuild command: ${MCSC_buildcmd}\nOutput\n${COMPILE_mcsc_VAR}") - endif() - file(REMOVE "${CMAKE_BINARY_DIR}/testprog*") - - if(EXISTS "${CMAKE_BINARY_DIR}/conftestval") - file(READ "${CMAKE_BINARY_DIR}/conftestval" mcsc) - STRING(REPLACE "\n" "" mcsc "${mcsc}") - if(mcsc) - set(mcsc "yes") - set(HAVE_UCONTEXT_H 1) - else() - set(mcsc "no") - endif() - else() - set(mcsc "no") - endif() - - message(STATUS "mcsc: ${mcsc}") -ENDIF() - -if(mcsc MATCHES "no" AND pthread) - if(HAVE_WINDOWS_H) - set(windows_context "yes") - set(IS_WINDOWS 1) - elseif(HAVE_WINDOWS_H) - message(FATAL_ERROR "no appropriate backend found") - endif() -endif() - -#Only windows - -if(WIN32) - if(NOT HAVE_WINDOWS_H) - message(FATAL_ERROR "no appropriate backend found windows") - endif() -endif() - -if(windows_context MATCHES "yes") - message(STATUS "Context change to windows") + # We always provide our own implementation of ucontext on Windows. + try_compile(HAVE_UCONTEXT + ${CMAKE_BINARY_DIR} + ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_AC_CHECK_MCSC.c + COMPILE_DEFINITIONS _XBT_WIN32 + INCLUDE_DIRECTORIES + ${CMAKE_HOME_DIRECTORY}/src/include + ${CMAKE_HOME_DIRECTORY}/src/xbt + ) +else() + # We always provide our own implementation of ucontext on Windows. + try_compile(HAVE_UCONTEXT + ${CMAKE_BINARY_DIR} + ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_AC_CHECK_MCSC.c) endif() #If can have both context -if(mcsc) +if(HAVE_UCONTEXT) set(CONTEXT_UCONTEXT 1) + message("-- Support for ucontext factory") endif() -if(pthread) +if(HAVE_PTHREAD) set(CONTEXT_THREADS 1) + message("-- Support for thread context factory") endif() ############### @@ -562,15 +539,15 @@ elseif(EXISTS ${CMAKE_HOME_DIRECTORY}/.gitversion) endif() if(release) - set(SIMGRID_VERSION_STRING "${SIMGRID_VERSION_STRING}\\nRelease build") + set(SIMGRID_VERSION_BANNER "${SIMGRID_VERSION_BANNER}\\nRelease build") else() - set(SIMGRID_VERSION_STRING "${SIMGRID_VERSION_STRING}\\nDevelopment build") + set(SIMGRID_VERSION_BANNER "${SIMGRID_VERSION_BANNER}\\nDevelopment build") endif() if(GIT_VERSION) - set(SIMGRID_VERSION_STRING "${SIMGRID_VERSION_STRING} at commit ${GIT_VERSION}") + set(SIMGRID_VERSION_BANNER "${SIMGRID_VERSION_BANNER} at commit ${GIT_VERSION}") endif() if(GIT_DATE) - set(SIMGRID_VERSION_STRING "${SIMGRID_VERSION_STRING} (${GIT_DATE})") + set(SIMGRID_VERSION_BANNER "${SIMGRID_VERSION_BANNER} (${GIT_DATE})") endif() #-------------------------------------------------------------------------------------------------- @@ -578,7 +555,7 @@ set(makecontext_CPPFLAGS_2 "") if(HAVE_MAKECONTEXT OR WIN32) set(makecontext_CPPFLAGS "-DTEST_makecontext") if(CMAKE_SYSTEM_NAME MATCHES "Darwin") - set(makecontext_CPPFLAGS_2 "-D_XOPEN_SOURCE") + set(makecontext_CPPFLAGS_2 "-D_XOPEN_SOURCE=700") endif() if(WIN32) @@ -592,11 +569,16 @@ if(HAVE_MAKECONTEXT OR WIN32) file(REMOVE ${CMAKE_BINARY_DIR}/conftestval) - try_run(RUN_makecontext_VAR COMPILE_makecontext_VAR - ${CMAKE_BINARY_DIR} - ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_stacksetup.c - COMPILE_DEFINITIONS "${makecontext_CPPFLAGS} ${makecontext_CPPFLAGS_2}" - ) + if(CMAKE_CROSSCOMPILING) + set(RUN_makecontext_VAR "cross") + set(COMPILE_makecontext_VAR "cross") + else() + try_run(RUN_makecontext_VAR COMPILE_makecontext_VAR + ${CMAKE_BINARY_DIR} + ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_stacksetup.c + COMPILE_DEFINITIONS "${makecontext_CPPFLAGS} ${makecontext_CPPFLAGS_2}" + ) + endif() if(EXISTS ${CMAKE_BINARY_DIR}/conftestval) file(READ ${CMAKE_BINARY_DIR}/conftestval MAKECONTEXT_ADDR_SIZE) @@ -621,16 +603,23 @@ if (NOT CMAKE_CROSSCOMPILING) try_run(RUN_makecontext_VAR COMPILE_makecontext_VAR ${CMAKE_BINARY_DIR} ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_stackgrowth.c + RUN_OUTPUT_VARIABLE stack ) - file(READ "${CMAKE_BINARY_DIR}/conftestval" stack) - if(stack MATCHES "down") +endif() +if("${stack}" STREQUAL "down") + set(PTH_STACKGROWTH "-1") +elseif("${stack}" STREQUAL "up") + set(PTH_STACKGROWTH "1") +else() + if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64") set(PTH_STACKGROWTH "-1") + elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i686") + set(PTH_STACKGROWTH "-1") + else() + message(ERROR "Could not figure the stack direction.") endif() - if(stack MATCHES "up") - set(PTH_STACKGROWTH "1") - endif() - endif() + ############### ## System checks ## @@ -641,18 +630,6 @@ endif() #AC_PROG_MAKE_SET -#AC_PRINTF_NULL FIXME: this is too ancient to survive! -try_run(RUN_PRINTF_NULL_VAR COMPILE_PRINTF_NULL_VAR - ${CMAKE_BINARY_DIR} - ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_printf_null.c - ) - -if(RUN_PRINTF_NULL_VAR MATCHES "FAILED_TO_RUN") - SET(PRINTF_NULL_WORKING "0") -else() - SET(PRINTF_NULL_WORKING "1") -endif() - #AC_CHECK_VA_COPY set(diff_va "va_copy((d),(s))" @@ -845,11 +822,8 @@ set(includeflag "-I${CMAKE_INSTALL_PREFIX}/include -I${CMAKE_INSTALL_PREFIX}/inc set(includedir "${CMAKE_INSTALL_PREFIX}/include") set(libdir ${exec_prefix}/lib) set(CMAKE_SMPI_COMMAND "export LD_LIBRARY_PATH=\"${CMAKE_INSTALL_PREFIX}/lib") -if(GTNETS_LIB_PATH) - set(CMAKE_SMPI_COMMAND "${CMAKE_SMPI_COMMAND}:${GTNETS_LIB_PATH}") -endif() -if(HAVE_NS3_LIB) - set(CMAKE_SMPI_COMMAND "${CMAKE_SMPI_COMMAND}:${HAVE_NS3_LIB}") +if(NS3_LIBRARY_PATH) + set(CMAKE_SMPI_COMMAND "${CMAKE_SMPI_COMMAND}:${NS3_LIBRARY_PATH}") endif() set(CMAKE_SMPI_COMMAND "${CMAKE_SMPI_COMMAND}:\${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}\"") @@ -867,11 +841,8 @@ set(includeflag "${includeflag} -I${CMAKE_BINARY_DIR}/include -I${CMAKE_BINARY_D set(includedir "${CMAKE_HOME_DIRECTORY}/include") set(exec_prefix "${CMAKE_BINARY_DIR}/smpi_script/") set(CMAKE_SMPI_COMMAND "export LD_LIBRARY_PATH=\"${CMAKE_BINARY_DIR}/lib") -if(GTNETS_LIB_PATH) - set(CMAKE_SMPI_COMMAND "${CMAKE_SMPI_COMMAND}:${GTNETS_LIB_PATH}") -endif() -if(HAVE_NS3_LIB) - set(CMAKE_SMPI_COMMAND "${CMAKE_SMPI_COMMAND}:${HAVE_NS3_LIB}") +if(NS3_LIBRARY_PATH) + set(CMAKE_SMPI_COMMAND "${CMAKE_SMPI_COMMAND}:${NS3_LIBRARY_PATH}") endif() set(CMAKE_SMPI_COMMAND "${CMAKE_SMPI_COMMAND}:\${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}\"") set(libdir "${CMAKE_BINARY_DIR}/lib")