CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
project(omp_test)
find_package(OpenMP REQUIRED)
if (OPENMP_FOUND)
message("OpenMP found!")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()
add_executable(omp_test omp_test.cpp)
omp_test.cpp
#include <iostream>
#include <string>
#include <omp.h>
using namespace std;
int main(){
int numProcs = omp_get_num_procs();
cout << "omp_get_num_procs() = " << numProcs << endl;
return 0;
}