Skip to content

Commit

Permalink
update pthread detection and system config
Browse files Browse the repository at this point in the history
  • Loading branch information
Karry committed Jan 6, 2024
1 parent f0e47c9 commit 363f618
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
22 changes: 16 additions & 6 deletions CMakeMod/Config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
28 changes: 28 additions & 0 deletions CMakeMod/features.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 363f618

Please sign in to comment.