-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathac_build_prj_util.cmake
46 lines (39 loc) · 1.53 KB
/
ac_build_prj_util.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
# Copyright (c) Alpaca Core
# SPDX-License-Identifier: MIT
#
include_guard(GLOBAL)
function(add_ac_subdir)
cmake_parse_arguments(ARG "" "NAME;TARGET;VERSION;GITHUB" "" ${ARGN})
if(NOT TARGET ${ARG_TARGET})
if(AC_BUILD_COMPONENT)
find_package(${ARG_NAME} ${ARG_VERSION} REQUIRED)
elseif(AC_BUILD_MONO)
add_subdirectory("${CMAKE_SOURCE_DIR}/../${ARG_NAME}" ${ARG_NAME})
if(NOT ${ARG_NAME}_VERSION VERSION_EQUAL ARG_VERSION)
message(FATAL_ERROR "${ARG_NAME} version mismatch. Expected ${ARG_VERSION}. Got ${${ARG_NAME}_VERSION}")
endif()
set(${ARG_NAME}_ROOT "${CMAKE_CURRENT_BINARY_DIR}/${ARG_NAME}"
CACHE PATH "ac-build: find_package path to ${ARG_NAME}" FORCE)
else() # standalone or deploy
CPMAddPackage(
NAME ${ARG_NAME}
VERSION ${ARG_VERSION}
SYSTEM FALSE # not system, so that it's installable
GITHUB_REPOSITORY ${ARG_GITHUB}
)
if(NOT ${ARG_NAME}_ADDED)
message(FATAL_ERROR "Adding ac-build project ${ARG_NAME} multiple times")
endif()
set(${ARG_NAME}_ROOT "${${ARG_NAME}_BINARY_DIR}"
CACHE PATH "ac-build: find_package path to ${ARG_NAME}" FORCE)
endif()
endif()
endfunction()
macro(add_ac_local acLocalVersion)
add_ac_subdir(
NAME ac-local
TARGET ac::local
VERSION ${acLocalVersion}
GITHUB "alpaca-core/ac-local"
)
endmacro()