This repository has been archived by the owner on Jun 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
BuildSupport.cmake
80 lines (64 loc) · 3.05 KB
/
BuildSupport.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
68
69
70
71
72
73
74
75
76
77
78
79
# Initialize FlyEM build variables
#
# Sets the following variables:
#
# BUILDEM_BIN_DIR Binary directory (/bin) for BPD
# BUILDEM_LIB_DIR Library directory (/lib) for BPD
# BUILDEM_SRC_DIR Source directory (/src) for BPD
# BUILDEM_INCLUDE_DIR Include directory (/include) for BPD
#
# BUILDEM_BIN_PATH Command path string suitable for PATH env variable.
# BUILDEM_LIB_PATH Library path string suitable for LD_LIBRARY_PATH env variable.
# BUILDEM_ENV_STRING Environment variable setting string for use before commands.
if (NOT BUILDEM_ENV_STRING)
if (NOT BUILDEM_DIR)
message (FATAL_ERROR "ERROR: BuildEM build directory (for all downloads & builds) should be specified via -DBUILDEM_DIR=<path> on cmake command line.")
endif ()
if (NOT BUILDEM_REPO_DIR)
message (FATAL_ERROR "ERROR: BUILDEM_REPO_DIR must be specified via your application's CMakeLists.txt file, and must be set to ${BUILDEM_DIR}/src/buildem.")
endif ()
# Make sure the main directories for FlyEM build directory are already
# created so paths won't error out.
set (BUILDEM_BIN_DIR ${BUILDEM_DIR}/bin)
if (NOT EXISTS ${BUILDEM_BIN_DIR})
file (MAKE_DIRECTORY ${BUILDEM_BIN_DIR})
endif ()
set (BUILDEM_TEST_DIR ${BUILDEM_DIR}/bin/tests)
if (NOT EXISTS ${BUILDEM_TEST_DIR})
file (MAKE_DIRECTORY ${BUILDEM_TEST_DIR})
endif ()
set (BUILDEM_LIB_DIR ${BUILDEM_DIR}/lib)
if (NOT EXISTS ${BUILDEM_LIB_DIR})
file (MAKE_DIRECTORY ${BUILDEM_LIB_DIR})
endif ()
set (BUILDEM_INCLUDE_DIR ${BUILDEM_DIR}/include)
if (NOT EXISTS ${BUILDEM_INCLUDE_DIR})
file (MAKE_DIRECTORY ${BUILDEM_INCLUDE_DIR})
endif ()
set (BUILDEM_SRC_DIR ${BUILDEM_DIR}/src)
if (NOT EXISTS ${BUILDEM_SRC_DIR})
file (MAKE_DIRECTORY ${BUILDEM_SRC_DIR})
endif ()
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# Important to use FALLBACK variable.
# https://developer.apple.com/library/mac/#documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryUsageGuidelines.html
set (BUILDEM_LD_LIBRARY_VAR "DYLD_FALLBACK_LIBRARY_PATH")
set (BUILDEM_PLATFORM_SPECIFIC_ENV "MACOSX_DEPLOYMENT_TARGET=10.5")
set (BUILDEM_PLATFORM_DYLIB_EXTENSION "dylib")
else()
set (BUILDEM_LD_LIBRARY_VAR "LD_LIBRARY_PATH")
set (BUILDEM_PLATFORM_SPECIFIC_ENV "")
set (BUILDEM_PLATFORM_DYLIB_EXTENSION "so")
endif()
# Initialize environment variables string to use for commands.
set (BUILDEM_BIN_PATH ${BUILDEM_BIN_DIR}:$ENV{PATH})
set (BUILDEM_LIB_PATH ${BUILDEM_LIB_DIR}:$ENV{${BUILDEM_LD_LIBRARY_VAR}})
set (BUILDEM_ENV_STRING env PATH=${BUILDEM_BIN_PATH} ${BUILDEM_LD_LIBRARY_VAR}=${BUILDEM_LIB_PATH} ${BUILDEM_PLATFORM_SPECIFIC_ENV})
set (BUILDEM_LDFLAGS "-Wl,-rpath,${BUILDEM_LIB_DIR} -L${BUILDEM_LIB_DIR}")
# All library builds should go to BPD/lib
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${BUILDEM_LIB_DIR})
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${BUILDEM_LIB_DIR})
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BUILDEM_BIN_DIR})
# Set standard include directories.
include_directories (BEFORE ${BUILDEM_INCLUDE_DIR})
endif (NOT BUILDEM_ENV_STRING)