http://public.kitware.com/Bug/view.php?id=11910 --- Modules/FindOpenMP.cmake 2011-03-01 17:34:59.000000000 +0900 +++ Modules/FindOpenMP.cmake 2011-03-01 17:35:26.000000000 +0900 @@ -72,41 +72,53 @@ endif(DEFINED OpenMP_C_FLAGS AND DEFINED OpenMP_CXX_FLAGS) # check c compiler -foreach(FLAG ${OpenMP_C_FLAG_CANDIDATES}) - set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") - set(CMAKE_REQUIRED_FLAGS "${FLAG}") - unset(OpenMP_FLAG_DETECTED CACHE) - message(STATUS "Try OpenMP C flag = [${FLAG}]") - check_c_source_compiles("${OpenMP_CXX_TEST_SOURCE}" OpenMP_FLAG_DETECTED) - set(CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}") - if(OpenMP_FLAG_DETECTED) - set(OpenMP_C_FLAGS_INTERNAL "${FLAG}") - break() - endif(OpenMP_FLAG_DETECTED) -endforeach(FLAG ${OpenMP_C_FLAG_CANDIDATES}) +IF (CMAKE_C_COMPILER) + foreach(FLAG ${OpenMP_C_FLAG_CANDIDATES}) + set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") + set(CMAKE_REQUIRED_FLAGS "${FLAG}") + unset(OpenMP_FLAG_DETECTED CACHE) + message(STATUS "Try OpenMP C flag = [${FLAG}]") + check_c_source_compiles("${OpenMP_C_TEST_SOURCE}" OpenMP_FLAG_DETECTED) + set(CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}") + if(OpenMP_FLAG_DETECTED) + set(OpenMP_C_FLAGS_INTERNAL "${FLAG}") + break() + endif(OpenMP_FLAG_DETECTED) + endforeach(FLAG ${OpenMP_C_FLAG_CANDIDATES}) +ENDIF (CMAKE_C_COMPILER) # check cxx compiler -foreach(FLAG ${OpenMP_CXX_FLAG_CANDIDATES}) - set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") - set(CMAKE_REQUIRED_FLAGS "${FLAG}") - unset(OpenMP_FLAG_DETECTED CACHE) - message(STATUS "Try OpenMP CXX flag = [${FLAG}]") - check_cxx_source_compiles("${OpenMP_C_TEST_SOURCE}" OpenMP_FLAG_DETECTED) - set(CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}") - if(OpenMP_FLAG_DETECTED) - set(OpenMP_CXX_FLAGS_INTERNAL "${FLAG}") - break() - endif(OpenMP_FLAG_DETECTED) -endforeach(FLAG ${OpenMP_CXX_FLAG_CANDIDATES}) +IF (CMAKE_CXX_COMPILER) + foreach(FLAG ${OpenMP_CXX_FLAG_CANDIDATES}) + set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") + set(CMAKE_REQUIRED_FLAGS "${FLAG}") + unset(OpenMP_FLAG_DETECTED CACHE) + message(STATUS "Try OpenMP CXX flag = [${FLAG}]") + check_cxx_source_compiles("${OpenMP_CXX_TEST_SOURCE}" OpenMP_FLAG_DETECTED) + set(CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}") + if(OpenMP_FLAG_DETECTED) + set(OpenMP_CXX_FLAGS_INTERNAL "${FLAG}") + break() + endif(OpenMP_FLAG_DETECTED) + endforeach(FLAG ${OpenMP_CXX_FLAG_CANDIDATES}) +ENDIF (CMAKE_CXX_COMPILER) set(OpenMP_C_FLAGS "${OpenMP_C_FLAGS_INTERNAL}" CACHE STRING "C compiler flags for OpenMP parallization") set(OpenMP_CXX_FLAGS "${OpenMP_CXX_FLAGS_INTERNAL}" CACHE STRING "C++ compiler flags for OpenMP parallization") + # handle the standard arguments for find_package -find_package_handle_standard_args(OpenMP DEFAULT_MSG - OpenMP_C_FLAGS OpenMP_CXX_FLAGS ) +IF (CMAKE_C_COMPILER) + find_package_handle_standard_args(OpenMP DEFAULT_MSG + OpenMP_C_FLAGS ) +ENDIF (CMAKE_C_COMPILER) + +IF (CMAKE_CXX_COMPILER) + find_package_handle_standard_args(OpenMP DEFAULT_MSG + OpenMP_CXX_FLAGS ) +ENDIF (CMAKE_CXX_COMPILER) mark_as_advanced( OpenMP_C_FLAGS