diff --git a/CMakeMod/Config.h.cmake b/CMakeMod/Config.h.cmake index 4c119c6d0..c0a6251e1 100644 --- a/CMakeMod/Config.h.cmake +++ b/CMakeMod/Config.h.cmake @@ -201,6 +201,16 @@ #cmakedefine HAVE_VISIBILITY 1 #endif +/* Define to 1 or 0, depending whether the compiler supports parallel execution algorithms. */ +#ifndef HAVE_STD_EXECUTION +#cmakedefine HAVE_STD_EXECUTION 1 +#endif + +/* Define to 1 or 0, depending whether the tbb::task_scheduler_init exists. */ +#ifndef TBB_HAS_SCHEDULER_INIT +#cmakedefine TBB_HAS_SCHEDULER_INIT 1 +#endif + /* int16_t is available */ #ifndef OSMSCOUT_HAVE_INT16_T #cmakedefine OSMSCOUT_HAVE_INT16_T 1 @@ -371,14 +381,14 @@ #cmakedefine OSMSCOUT_MAP_SVG_HAVE_LIB_PANGO 1 #endif -/* gl/glut */ -#ifndef OSMSCOUT_MAP_OPENGL_HAVE_GL_GLUT_H -#cmakedefine OSMSCOUT_MAP_OPENGL_HAVE_GL_GLUT_H 1 +#ifndef OSMSCOUT_PTHREAD +/* Threads are pthreads */ +#cmakedefine OSMSCOUT_PTHREAD #endif -/* glut/glut */ -#ifndef OSMSCOUT_MAP_OPENGL_HAVE_GLUT_GLUT_H -#cmakedefine OSMSCOUT_MAP_OPENGL_HAVE_GLUT_GLUT_H 1 +#ifndef OSMSCOUT_PTHREAD_NAME +/* Threads are pthreads and non-posix setname is available */ +#cmakedefine OSMSCOUT_PTHREAD_NAME #endif #endif // @OSMSCOUT_PRIVATE_CONFIG_HEADER_NAME@_PRIVATE_CONFIG_H diff --git a/CMakeMod/features.cmake b/CMakeMod/features.cmake index 39977d3be..7e43a6fe9 100644 --- a/CMakeMod/features.cmake +++ b/CMakeMod/features.cmake @@ -118,6 +118,34 @@ set(OSMSCOUT_HAVE_INT8_T ${HAVE_INT8_T}) set(OSMSCOUT_HAVE_SSE2 ${HAVE_SSE2}) set(OSMSCOUT_GPX_HAVE_LIB_XML ${LIBXML2_FOUND}) +find_package(Threads) +if(THREADS_HAVE_PTHREAD_ARG) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${THREADS_PTHREAD_ARG}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${THREADS_PTHREAD_ARG}") +endif() + +if (CMAKE_USE_PTHREADS_INIT) + set(OSMSCOUT_PTHREAD TRUE) +endif() + +try_compile(PTHREAD_NAME_OK "${PROJECT_BINARY_DIR}" + "${PROJECT_SOURCE_DIR}/dependencies/libosmscout/cmake/TestPThreadName.cpp" + LINK_LIBRARIES pthread + OUTPUT_VARIABLE PTHREAD_NAME_OUT) +if(PTHREAD_NAME_OK) + set(OSMSCOUT_PTHREAD_NAME TRUE) +else() + message(STATUS "TestPThreadName.cpp cannot be compiled: ${PTHREAD_NAME_OUT}") +endif() + +find_package(TBB QUIET) +if (TBB_FOUND) + try_compile(TBB_HAS_SCHEDULER_INIT "${PROJECT_BINARY_DIR}" + "${PROJECT_SOURCE_DIR}/dependencies/libosmscout/cmake/TestTBBSchedulerInit.cpp" + LINK_LIBRARIES TBB::tbb) +endif() +set(HAVE_STD_EXECUTION ${TBB_FOUND}) + function(create_private_config output name) string(REPLACE "-" "_" OSMSCOUT_PRIVATE_CONFIG_HEADER_NAME ${name}) string(TOUPPER ${OSMSCOUT_PRIVATE_CONFIG_HEADER_NAME} OSMSCOUT_PRIVATE_CONFIG_HEADER_NAME)