X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/0853a0e21ddf334c2e7890a33fbdc3a281d30b0b..558cfc9fc06c8d1a7206b5995d3736cc11319529:/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 144bea937e..c22fc86ed1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -186,6 +186,7 @@ include_directories(${INCLUDES}) include(${CMAKE_HOME_DIRECTORY}/tools/cmake/Option.cmake) ### Determine the assembly flavor that we need today +set(HAVE_RAW_CONTEXTS 0) include(CMakeDetermineSystem) IF(CMAKE_SYSTEM_PROCESSOR MATCHES ".86|AMD64|amd64") IF(${ARCH_32_BITS}) @@ -198,7 +199,7 @@ IF(CMAKE_SYSTEM_PROCESSOR MATCHES ".86|AMD64|amd64") set(PROCESSOR_x86_64 1) ENDIF() if (WIN32) - message(STATUS "Disable fast raw contextes on Windows.") + message(STATUS "Disable fast raw contexts on Windows.") else() set(HAVE_RAW_CONTEXTS 1) endif() @@ -287,15 +288,6 @@ else() set(CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE") endif() -SET(HAVE_VALGRIND_H 0) -SET(HAVE_UNISTD_H 0) -SET(HAVE_EXECINFO_H 0) -SET(HAVE_SIGNAL_H 0) -SET(HAVE_SYS_PARAM_H 0) -SET(HAVE_SYS_SYSCTL_H 0) -SET(HAVE_UCONTEXT_H 0) -SET(HAVE_FUTEX_H 0) - CHECK_INCLUDE_FILE("valgrind/valgrind.h" HAVE_VALGRIND_H) CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H) CHECK_INCLUDE_FILE("execinfo.h" HAVE_EXECINFO_H) @@ -305,14 +297,6 @@ CHECK_INCLUDE_FILE("sys/sysctl.h" HAVE_SYS_SYSCTL_H) CHECK_INCLUDE_FILE("ucontext.h" HAVE_UCONTEXT_H) CHECK_INCLUDE_FILE("linux/futex.h" HAVE_FUTEX_H) -SET(HAVE_GETTIMEOFDAY 0) -SET(HAVE_NANOSLEEP 0) -SET(HAVE_GETDTABLESIZE 0) -SET(HAVE_SYSCONF 0) -SET(HAVE_POPEN 0) -SET(HAVE_PROCESS_VM_READV 0) -SET(HAVE_MMAP 0) - CHECK_FUNCTION_EXISTS(gettimeofday HAVE_GETTIMEOFDAY) CHECK_FUNCTION_EXISTS(nanosleep HAVE_NANOSLEEP) CHECK_FUNCTION_EXISTS(getdtablesize HAVE_GETDTABLESIZE) @@ -321,16 +305,14 @@ CHECK_FUNCTION_EXISTS(popen HAVE_POPEN) CHECK_FUNCTION_EXISTS(process_vm_readv HAVE_PROCESS_VM_READV) CHECK_FUNCTION_EXISTS(mmap HAVE_MMAP) -SET(HAVE_VASPRINTF 0) CHECK_SYMBOL_EXISTS(vasprintf stdio.h HAVE_VASPRINTF) -if(MINGW) +if(MINGW) # The detection of vasprintf fails on MinGW, assumingly because it's # defined as an inline function in stdio.h instead of a regular # function. So force the result to be 1 despite of the test. set(HAVE_VASPRINTF 1) endif() - #Check if __thread is defined execute_process( COMMAND "${CMAKE_C_COMPILER} ${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_thread_storage.c -o testprog" @@ -649,6 +631,24 @@ endif() ### Generate the required headers and scripts ############################################# + +# gcc makes no difference between "#define HAVE_FOOBAR" and "#define HAVE_FOOBAR 0" by default, +# but this too error prone. If you forget to include the config.h, you get weird segfaults. +# If you include it everywhere, everything gets recompiled everytime. +# So we include only where needed, and compile with -Wundef to notice the missing includes. +# But cmake sometimes defines to the empty definition (#define HAVE_VALGRIND_H). +# So we have to make sure that everything got a decent value before generating the files. +foreach(var HAVE_EXECINFO_H HAVE_FUTEX_H HAVE_GETDTABLESIZE HAVE_GETTIMEOFDAY HAVE_MMAP + HAVE_NANOSLEEP HAVE_POPEN HAVE_POSIX_GETTIME HAVE_PROCESS_VM_READV HAVE_SIGNAL_H + HAVE_SYS_PARAM_H HAVE_SYS_SYSCTL_H HAVE_SYSCONF HAVE_UCONTEXT_H HAVE_UNISTD_H + HAVE_VALGRIND_H HAVE_VASPRINTF) + if(${var}) + set(${var} 1) + else() + set(${var} 0) + endif() +endforeach() + # Avoid triggering a (full) rebuild by touching the files if they did not really change configure_file("${CMAKE_HOME_DIRECTORY}/tools/cmake/src/internal_config.h.in" "${CMAKE_BINARY_DIR}/src/internal_config.h.generated" @ONLY IMMEDIATE) configure_file("${CMAKE_HOME_DIRECTORY}/include/simgrid_config.h.in" "${CMAKE_BINARY_DIR}/include/simgrid_config.h.generated" @ONLY IMMEDIATE) @@ -894,7 +894,7 @@ message("##########################################") message("#### Content of src/internal_config.h ####") message("##########################################") file(STRINGS ${CMAKE_CURRENT_BINARY_DIR}/src/internal_config.h config_output) -LIST(REMOVE_AT config_output 0 1 2 3 4 5 6 7 8) # Pass the file header +LIST(REMOVE_AT config_output 0 1 2 3 4 5 6 7 8 9 10) # Pass the file header foreach(line ${config_output}) message(" ${line}") endforeach()