Merge pull request #1364 from Project-OSRM/feature/check_libgomp
check if stxxl compiles with or without libgomp, fixes #1361
This commit is contained in:
		
						commit
						4195b0d0e6
					
				| @ -176,7 +176,7 @@ endif() | ||||
| 
 | ||||
| # Activate C++11 | ||||
| if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") | ||||
|   ADD_DEFINITIONS(-std=c++11) | ||||
|   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 ") | ||||
| endif() | ||||
| 
 | ||||
| # Configuring other platform dependencies | ||||
| @ -265,6 +265,9 @@ target_link_libraries(OSRM ${STXXL_LIBRARY}) | ||||
| target_link_libraries(osrm-extract ${STXXL_LIBRARY}) | ||||
| target_link_libraries(osrm-prepare ${STXXL_LIBRARY}) | ||||
| 
 | ||||
| # check if we need to link against libgomp | ||||
| include(check_stxxl) | ||||
| 
 | ||||
| if(MINGW) | ||||
|   # STXXL needs OpenMP library | ||||
|   target_link_libraries(osrm-extract gomp) | ||||
|  | ||||
							
								
								
									
										24
									
								
								cmake/check_stxxl.cmake
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								cmake/check_stxxl.cmake
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,24 @@ | ||||
| INCLUDE (CheckCXXSourceCompiles) | ||||
| unset(STXXL_WORKS CACHE) | ||||
| set (STXXL_CHECK_SRC "#include <stxxl/vector>\n int main() { stxxl::vector<int> vec; return 0;}") | ||||
| set (CMAKE_TRY_COMPILE_CONFIGURATION ${CMAKE_BUILD_TYPE}) | ||||
| set (CMAKE_REQUIRED_INCLUDES "${STXXL_INCLUDE_DIR}") | ||||
| set (CMAKE_REQUIRED_LIBRARIES "${STXXL_LIBRARY}") | ||||
| 
 | ||||
| CHECK_CXX_SOURCE_COMPILES("${STXXL_CHECK_SRC}" STXXL_WORKS) | ||||
| 
 | ||||
| if(STXXL_WORKS) | ||||
|   message(STATUS "STXXL can be used without linking against libgomp") | ||||
| else() | ||||
|   message(STATUS "Linking STXXL failed without libgomp, retrying ..") | ||||
|   find_package(OpenMP) | ||||
|   set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}${OpenMP_CXX_FLAGS}") | ||||
|   CHECK_CXX_SOURCE_COMPILES("${STXXL_CHECK_SRC}" STXXL_LINKS) | ||||
| 
 | ||||
|   if (STXXL_LINKS) | ||||
|     message(STATUS "STXXL needs to link against OpenMP") | ||||
|     target_link_libraries(osrm-extract gomp) | ||||
|   else() | ||||
|     message(FATAL_ERROR "STXXL failed failed, libgomp missing?") | ||||
|   endif() | ||||
| endif() | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user