forked from rraju1/cmake-buildscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RunnablePrograms.cmake
55 lines (41 loc) · 2.16 KB
/
RunnablePrograms.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
# File that handles using an installation of Amber Host Tools to (cross-)compile Amber
# This sets the RUNNABLE_<program> variables for the rest of the build system to the versions of each program that can be run on the build system.
# Must be included after MPIConfig
set(EXECUTABLES_TO_IMPORT byacc ucpp utilMakeHelp nab2c mpinab2c rule_parse)
set(EXECUTABLES_TO_IMPORT_REQUIRED TRUE TRUE TRUE TRUE ${MPI} TRUE) # true if the corresponding executable is needed to build Amber
if(USE_HOST_TOOLS)
if(NOT EXISTS ${HOST_TOOLS_DIR})
message(FATAL_ERROR "Provided Amber Host Tools directory does not exist. Please set HOST_TOOLS_DIR to a valid host tools directory to use host tools")
endif()
#import executables as "host_" versions
foreach(EXECUTABLE ${EXECUTABLES_TO_IMPORT})
# we do not know the host executable suffix, so we have to do a file search to figure out the last part of the filename
file(GLOB EXECUTABLE_PATH_POSSIBILITIES "${HOST_TOOLS_DIR}/bin/${EXECUTABLE}*")
list(LENGTH EXECUTABLE_PATH_POSSIBILITIES NUM_POSSIBILITIES)
if(${NUM_POSSIBILITIES} EQUAL 1)
set(EXECUTABLE_PATH ${EXECUTABLE_PATH_POSSIBILITIES})
import_executable(${EXECUTABLE}_host ${EXECUTABLE_PATH})
#the runnable versions are the host tools versions
set(RUNNABLE_${EXECUTABLE} ${EXECUTABLE}_host)
set(HAVE_RUNNABLE_${EXECUTABLE} TRUE)
else()
# find out if we actually need this program
list(FIND EXECUTABLES_TO_IMPORT ${EXECUTABLE} CURR_EXECUTABLE_INDEX)
list(GET EXECUTABLES_TO_IMPORT_REQUIRED ${CURR_EXECUTABLE_INDEX} CURR_EXECUTABLE_REQUIRED)
if(CURR_EXECUTABLE_REQUIRED)
# print an error if it was not found
if(${NUM_POSSIBILITIES} GREATER 1)
message(FATAL_ERROR "Multiple candidates for executable ${EXECUTABLE} in directory ${HOST_TOOLS_DIR}/bin")
else()
message(FATAL_ERROR "Provided Amber Host Tools directory (${HOST_TOOLS_DIR}) is missing the executable ${EXECUTABLE}")
endif()
endif()
endif()
endforeach()
else()
#the runnable versions are the built versions
foreach(EXECUTABLE ${EXECUTABLES_TO_IMPORT})
set(RUNNABLE_${EXECUTABLE} ${EXECUTABLE})
set(HAVE_RUNNABLE_${EXECUTABLE} TRUE)
endforeach()
endif()