diff --git a/CMakeLists.txt b/CMakeLists.txt index d9d01f5..9bfe65b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,12 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Debug) endif() +set(CMAKE_MODULE_PATH + ${CMAKE_MODULE_PATH} + ${CMAKE_SOURCE_DIR}/cmake/) + find_package(OpenMP REQUIRED) +find_package(GMP REQUIRED) set(SRCS src/Main.cpp) diff --git a/cmake/FindGMP.cmake b/cmake/FindGMP.cmake new file mode 100644 index 0000000..c85990d --- /dev/null +++ b/cmake/FindGMP.cmake @@ -0,0 +1,24 @@ +# SOURCE: http://stackoverflow.com/questions/29307862/error-linking-gmp-library +set(GMP_PREFIX "" CACHE PATH "path ") + +find_path(GMP_INCLUDE_DIR gmp.h gmpxx.h + PATHS ${GMP_PREFIX}/include /usr/include /usr/local/include ) + +find_library(GMP_LIBRARY NAMES gmp libgmp + PATHS ${GMP_PREFIX}/lib /usr/lib /usr/local/lib) + + +if(GMP_INCLUDE_DIR AND GMP_LIBRARY) + get_filename_component(GMP_LIBRARY_DIR ${GMP_LIBRARY} PATH) + set(GMP_FOUND TRUE) +endif() + +if(GMP_FOUND) + if(NOT GMP_FIND_QUIETLY) + MESSAGE(STATUS "Found GMP: ${GMP_LIBRARY}") + endif() +else() + if(GMP_FIND_REQUIRED) + message(FATAL_ERROR "Could not find GMP") + endif() +endif()