This repository has been archived by the owner on Sep 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
FindPrep.cmake
51 lines (31 loc) · 1.55 KB
/
FindPrep.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
find_program(PREP_PROGRAM prep)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(PREP
FOUND_VAR PREP_FOUND
REQUIRED_VARS PREP_PROGRAM)
function(prep_init)
if (NOT PREP_FOUND)
return()
endif()
set(options)
set(singleValueOpts)
set(multiValueOpts)
cmake_parse_arguments(PREP_INIT "${options}" "${singleValueOpts}" "${multiValueOpts}" ${ARGN})
set(PREP_INIT_PACKAGE_FILE ${CMAKE_CURRENT_LIST_DIR}/package.json)
if (NOT EXISTS ${PREP_INIT_PACKAGE_FILE})
message(FATAL_ERROR "${CMAKE_CURRENT_LIST_DIR} should contain a package.json")
endif()
set(PREP_INIT_REPOSITORY ${CMAKE_CURRENT_LIST_DIR})
exec_program(${PREP_PROGRAM} ${PREP_INIT_REPOSITORY} ARGS env prefix OUTPUT_VARIABLE PREP_INSTALL_PREFIX)
set(CMAKE_PREFIX_PATH "${PREP_INSTALL_PREFIX}:${CMAKE_PREFIX_PATH}")
exec_program(${PREP_PROGRAM} ${PREP_INIT_REPOSITORY} ARGS env cxxflags OUTPUT_VARIABLE PREP_CXX_FLAGS)
exec_program(${PREP_PROGRAM} ${PREP_INIT_REPOSITORY} ARGS env ld_library_path OUTPUT_VARIABLE PREP_LINKER_PATH)
add_compile_options(${PREP_CXX_FLAGS})
link_directories(${PREP_LINKER_PATH})
message(STATUS "Using prep repository at ${PREP_INSTALL_PREFIX}")
add_custom_target(prep-dependencies COMMAND ${PREP_PROGRAM} get
WORKING_DIRECTORY "${PREP_INIT_REPOSITORY}"
DEPENDS ${PREP_INIT_PACKAGE_FILE})
set(PREP_INIT_DEPENDENCIES prep-dependencies PARENT_SCOPE)
endfunction()
mark_as_advanced(PREP_PROGRAM PREP_INSTALL_PREFIX PREP_INIT_DEPENDENCIES)