-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathImportOppTarget.cmake
More file actions
48 lines (40 loc) · 1.65 KB
/
ImportOppTarget.cmake
File metadata and controls
48 lines (40 loc) · 1.65 KB
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
find_package(PythonInterp 3 REQUIRED)
#[==[.rst:
ImportOppTarget
---------------
*This documentation is still a stub!*
.. cmake:command:: import_opp_target
#]==]
macro(import_opp_target _target _opp_makefile)
# _cmake_target: generated CMake file with import target [optional argument]
if(${ARGC} GREATER 2)
set(_cmake_target "${ARGV2}")
else()
set(_cmake_target "${PROJECT_BINARY_DIR}/${_target}-targets.cmake")
endif()
# opp_makemake generated Makefile is required for proceeding
if(NOT EXISTS ${_opp_makefile})
message(FATAL_ERROR "Cannot import ${_target} because there is no opp_makemake file at ${_opp_makefile}")
endif()
# generate target file (prior to build system generation)
execute_process(
COMMAND ${PYTHON_EXECUTABLE} opp_cmake.py ${_opp_makefile} ${_cmake_target}
ERROR_VARIABLE _opp_cmake_error
RESULT_VARIABLE _opp_cmake_result
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
if(_opp_cmake_result)
message(STATUS "opp_cmake generated following error log")
message(SEND_ERROR ${_opp_cmake_error})
message(FATAL_ERROR "import_opp_target for ${_target} aborted due to above opp_cmake error")
endif()
# include import targets if generated successfully
if(EXISTS ${_cmake_target})
include(${_cmake_target})
else()
message(FATAL_ERROR "There is no ${_cmake_target} for OMNeT++ import of ${_target}")
endif()
# sanity check: included target file has to provide the expected target
if(NOT TARGET ${_target})
message(FATAL_ERROR "Import of target ${_target} from ${_opp_makefile} failed")
endif()
endmacro()