-
Notifications
You must be signed in to change notification settings - Fork 9
/
OverkitSubproject.cmake
67 lines (54 loc) · 2.36 KB
/
OverkitSubproject.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
# Copyright (c) 2020 Matthew J. Smith and Overkit contributors
# License: MIT (http://opensource.org/licenses/MIT)
include(CMakeParseArguments)
include(ExternalProject)
macro(configure_overkit)
set(CONFIGURE_OVERKIT_OPTION_NAMES QUIET)
set(CONFIGURE_OVERKIT_ONE_VALUE_NAMES SOURCE_DIR BINARY_DIR INSTALL_BIN_DIR INSTALL_LIB_DIR
INSTALL_INCLUDE_DIR)
set(CONFIGURE_OVERKIT_MULTI_VALUE_NAMES OPTIONS)
cmake_parse_arguments(CONFIGURE_OVERKIT_ARG "${CONFIGURE_OVERKIT_OPTION_NAMES}"
"${CONFIGURE_OVERKIT_ONE_VALUE_NAMES}" "${CONFIGURE_OVERKIT_MULTI_VALUE_NAMES}" ${ARGV})
file(MAKE_DIRECTORY ${CONFIGURE_OVERKIT_ARG_BINARY_DIR})
if(CONFIGURE_OVERKIT_ARG_QUIET)
set(CONFIGURE_OVERKIT_OUTPUT_QUIET OUTPUT_QUIET)
endif()
execute_process(
COMMAND "${CMAKE_COMMAND}" ${CONFIGURE_OVERKIT_ARG_OPTIONS} -DSUBPROJECT=ON
"${CONFIGURE_OVERKIT_ARG_SOURCE_DIR}"
WORKING_DIRECTORY ${CONFIGURE_OVERKIT_ARG_BINARY_DIR}
${CONFIGURE_OVERKIT_OUTPUT_QUIET}
)
externalproject_add(OverkitSubproject
PREFIX ${CONFIGURE_OVERKIT_ARG_BINARY_DIR}
SOURCE_DIR ${CONFIGURE_OVERKIT_ARG_SOURCE_DIR}
BINARY_DIR ${CONFIGURE_OVERKIT_ARG_BINARY_DIR}
INSTALL_DIR ""
CONFIGURE_COMMAND ""
INSTALL_COMMAND "${CMAKE_COMMAND}" -E echo_append ""
)
# CMake by default doesn't seem to rebuild subprojects when changes are made to their source files
externalproject_add_step(OverkitSubproject forcebuild
COMMAND "${CMAKE_COMMAND}" -E echo_append ""
DEPENDEES configure
DEPENDERS build
ALWAYS 1
)
find_package(Overkit QUIET CONFIG REQUIRED PATHS ${CONFIGURE_OVERKIT_ARG_BINARY_DIR} NO_DEFAULT_PATH)
foreach(LIBRARY ${Overkit_LIBRARIES})
add_dependencies(${LIBRARY} OverkitSubproject)
endforeach()
# No binaries yet
# if(NOT "${CONFIGURE_OVERKIT_ARG_INSTALL_BIN_DIR}" STREQUAL "")
# install(DIRECTORY "${CONFIGURE_OVERKIT_ARG_BINARY_DIR}/bin/" DESTINATION
# ${CONFIGURE_OVERKIT_ARG_INSTALL_BIN_DIR})
# endif()
if(NOT "${CONFIGURE_OVERKIT_ARG_INSTALL_LIB_DIR}" STREQUAL "")
install(DIRECTORY ${CONFIGURE_OVERKIT_ARG_BINARY_DIR}/lib/ DESTINATION
${CONFIGURE_OVERKIT_ARG_INSTALL_LIB_DIR})
endif()
if(NOT "${CONFIGURE_OVERKIT_ARG_INSTALL_INCLUDE_DIR}" STREQUAL "")
install(DIRECTORY ${CONFIGURE_OVERKIT_ARG_BINARY_DIR}/include/ DESTINATION
${CONFIGURE_OVERKIT_ARG_INSTALL_INCLUDE_DIR})
endif()
endmacro()