- if(HAVE_SEM_INIT_LIB)
- execute_process(COMMAND ${CMAKE_C_COMPILER} ${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_sem_init.c -lpthread -o sem_init
- 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")
- message(STATUS "HAVE_SEM_INIT_comp_output: ${HAVE_SEM_OPEN_comp_output}")
- else()
- set(HAVE_SEM_INIT 1)
- message(STATUS "sem_init is compilable")
- endif()
-
- # 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()
- 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()
- endif()
- file(REMOVE sem_init)
- endif()
-
- if(NOT HAVE_SEM_OPEN AND NOT HAVE_SEM_INIT)
- message(FATAL_ERROR "Semaphores are not usable (neither sem_open nor sem_init is both compilable and executable), but they are mandatory to threads (you may need to mount /dev).")
- endif()
-
-endif()
-
-# This is needed for ucontext on MacOS X:
-if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
- add_definitions(-D_XOPEN_SOURCE=700 -D_DARWIN_C_SOURCE)
-endif()
-try_compile(HAVE_UCONTEXT
- ${CMAKE_BINARY_DIR}
- ${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_AC_CHECK_MCSC.c)
-
-#If can have both context
-if(HAVE_UCONTEXT)
- set(HAVE_UCONTEXT_CONTEXTS 1)
- message("-- Support for ucontext factory")
-endif()
-
-if(HAVE_PTHREAD)
- set(HAVE_THREAD_CONTEXTS 1)
- message("-- Support for thread context factory")
-endif()
-
-###############
-## GIT version check
-##
-if(EXISTS ${CMAKE_HOME_DIRECTORY}/.git/)
- execute_process(COMMAND git remote
- COMMAND head -n 1
- WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/.git/
- OUTPUT_VARIABLE remote
- RESULT_VARIABLE ret
- )
- string(REPLACE "\n" "" remote "${remote}")
- #message(STATUS "Git remote: ${remote}")
- execute_process(COMMAND git config --get remote.${remote}.url
- WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/.git/
- OUTPUT_VARIABLE url
- RESULT_VARIABLE ret
- )
- string(REPLACE "\n" "" url "${url}")
- #message(STATUS "Git url: ${url}")
- if(url)
- execute_process(COMMAND git --git-dir=${CMAKE_HOME_DIRECTORY}/.git log --pretty=oneline --abbrev-commit -1
- WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/.git/
- OUTPUT_VARIABLE GIT_VERSION
- RESULT_VARIABLE ret
- )
- string(REPLACE "\n" "" GIT_VERSION "${GIT_VERSION}")
- message(STATUS "Git version: ${GIT_VERSION}")
- execute_process(COMMAND git --git-dir=${CMAKE_HOME_DIRECTORY}/.git log -n 1 --pretty=format:%ai .
- WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/.git/
- OUTPUT_VARIABLE GIT_DATE
- RESULT_VARIABLE ret
- )
- string(REPLACE "\n" "" GIT_DATE "${GIT_DATE}")
- message(STATUS "Git date: ${GIT_DATE}")
- string(REGEX REPLACE " .*" "" GIT_VERSION "${GIT_VERSION}")
-
- execute_process(COMMAND git --git-dir=${CMAKE_HOME_DIRECTORY}/.git log --pretty=format:%H -1
- WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/.git/
- OUTPUT_VARIABLE SIMGRID_GITHASH
- RESULT_VARIABLE ret
- )
- string(REPLACE "\n" "" SIMGRID_GITHASH "${SIMGRID_GITHASH}")
-
- endif()
-elseif(EXISTS ${CMAKE_HOME_DIRECTORY}/.gitversion)
- FILE(STRINGS ${CMAKE_HOME_DIRECTORY}/.gitversion GIT_VERSION)
-endif()
-
-if(GIT_VERSION)
- set(SIMGRID_VERSION_BANNER "${SIMGRID_VERSION_BANNER} at commit ${GIT_VERSION}")
-endif()
-if(GIT_DATE)
- set(SIMGRID_VERSION_BANNER "${SIMGRID_VERSION_BANNER} (${GIT_DATE})")
-endif()
-#--------------------------------------------------------------------------------------------------
-
-set(makecontext_CPPFLAGS_2 "")
-if(HAVE_UCONTEXT_H)
- set(makecontext_CPPFLAGS "-DTEST_makecontext")
- if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
- set(makecontext_CPPFLAGS_2 "-D_XOPEN_SOURCE=700")
- endif()
-
- file(REMOVE ${CMAKE_BINARY_DIR}/conftestval)
-
- if(CMAKE_CROSSCOMPILING)
- set(RUN_makecontext_VAR "cross")
- set(COMPILE_makecontext_VAR "cross")