-
Notifications
You must be signed in to change notification settings - Fork 77
/
Copy pathFindadolc.cmake
68 lines (53 loc) · 2.79 KB
/
Findadolc.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# - Try to find adolc
# Once done, this will define
#
# adolc_FOUND - system has adolc
# adolc_INCLUDE_DIRS - the adolc include directories
# adolc_LIBRARIES - link these to use adolc
find_package(PkgConfig)
include(FindPackageHandleStandardArgs)
pkg_check_modules(adolc QUIET IMPORTED_TARGET GLOBAL adolc)
if(${adolc_FOUND}) # if Adolc could be found by pkgconfig
add_library(adolc ALIAS PkgConfig::adolc)
else() # is it already installed locally by this file?
# sometimes, AdolC will be downloaded each time the user calls cmake. prevent this by searching compiled files in the build dir
find_path(adolc_INCLUDE_DIR adolc.h
HINTS ${CMAKE_BINARY_DIR}/adolc-build/include/
NO_CMAKE_PATH)
find_library(adolc_LIBRARY adolc
HINTS ${CMAKE_BINARY_DIR}/adolc-build/lib64
NO_CMAKE_PATH)
if(NOT EXISTS ${adolc_INCLUDE_DIR}) # if everything fails, download it
message(STATUS "AdolC has not been installed on this system and will be automatically added to this project.")
find_package(ColPack REQUIRED)
find_package(Python2 REQUIRED COMPONENTS Development)
# Download and unpack adolc at configure time
configure_file(cmake/CMakeLists-adolc.txt.in ${CMAKE_BINARY_DIR}/adolc-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/adolc-download/ )
if(result)
message(FATAL_ERROR "CMake step for adolc failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/adolc-download )
if(result)
message(FATAL_ERROR "Build step for adolc failed: ${result}")
endif()
add_library(adolc SHARED IMPORTED)
target_include_directories(adolc INTERFACE ${CMAKE_BINARY_DIR}/adolc-build/include)
set_target_properties(adolc PROPERTIES IMPORTED_LOCATION ${CMAKE_BINARY_DIR}/adolc-build/lib64)
find_package_handle_standard_args(adolc DEFAULT_MSG
${adolc_LIBRARIES} ${adolc_INCLUDE_DIRS})
else()
# handle the QUIETLY and REQUIRED arguments and set adolc_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(adolc DEFAULT_MSG
adolc_LIBRARY adolc_INCLUDE_DIR)
mark_as_advanced(adolc_INCLUDE_DIR adolc_LIBRARY )
add_library(adolc SHARED IMPORTED)
target_include_directories(adolc INTERFACE ${adolc_INCLUDE_DIR})
set_target_properties(adolc PROPERTIES IMPORTED_LOCATION ${CMAKE_BINARY_DIR}/adolc-build/lib64)
endif()
endif()