Skip to content

Commit 4e2e163

Browse files
committed
[cmake] Improve handling of OMSimulator.
- Add it as an ExternalProject. - Do not allow it to output things to the install directory while building - Insted give it a directory in the build dir as an install dir. Then once it installs things in there, we handle the actual installation manually. - Essentially, this prevents from populating anything in the install directory while building. - Add an imported library target for it. This can be used to link to it from our other targets. - Add install logic for it. - OMSimulator wants to start with a Makefiles to invoke the actual CMake operations. As a result it is designed with that in mind. While the current support from this side is not ideal, it should suffice for now.
1 parent ba7ee7b commit 4e2e163

File tree

1 file changed

+41
-10
lines changed

1 file changed

+41
-10
lines changed

omsimulator.cmake

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,53 @@
11

2-
# message(FATAL_ERROR "${CMAKE_LIBRARY_ARCHITECTURE}")
32

4-
add_custom_target(omsimulator
5-
COMMAND ${CMAKE_MAKE_PROGRAM} config-3rdParty
3+
include(ExternalProject)
4+
include(ProcessorCount)
5+
ProcessorCount(NUM_PROCESSPRS)
6+
7+
8+
ExternalProject_Add(OMSimulator_external
9+
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/OMSimulator
10+
PREFIX OMSimulator
11+
#--Configure step-------------
12+
CONFIGURE_COMMAND COMMAND ${CMAKE_MAKE_PROGRAM} -C ${CMAKE_CURRENT_SOURCE_DIR}/OMSimulator
13+
-j${NUM_PROCESSPRS}
14+
config-3rdParty
615
CERES=OFF
716
host_short=${CMAKE_LIBRARY_ARCHITECTURE}
817
CMAKE=${CMAKE_COMMAND}
9-
10-
COMMAND ${CMAKE_MAKE_PROGRAM} config-OMSimulator
18+
COMMAND ${CMAKE_MAKE_PROGRAM} -C ${CMAKE_CURRENT_SOURCE_DIR}/OMSimulator
19+
-j${NUM_PROCESSPRS}
20+
config-OMSimulator
1121
OMSYSIDENT=OFF
12-
OMBUILDDIR=${CMAKE_INSTALL_PREFIX}
22+
OMBUILDDIR=${CMAKE_CURRENT_BINARY_DIR}/OMSimulator
1323
host_short=${CMAKE_LIBRARY_ARCHITECTURE}
1424
CMAKE=${CMAKE_COMMAND}
15-
16-
COMMAND ${CMAKE_MAKE_PROGRAM} OMSimulator
17-
OMBUILDDIR=${CMAKE_INSTALL_PREFIX}
25+
#--Build step-----------------
26+
BUILD_COMMAND COMMAND ${CMAKE_MAKE_PROGRAM} -C ${CMAKE_CURRENT_SOURCE_DIR}/OMSimulator
27+
-j${NUM_PROCESSPRS}
28+
OMSimulator
29+
OMBUILDDIR=${CMAKE_CURRENT_BINARY_DIR}/OMSimulator
1830
host_short=${CMAKE_LIBRARY_ARCHITECTURE}
1931
CMAKE=${CMAKE_COMMAND}
32+
#--Install step---------------
33+
INSTALL_COMMAND ""
34+
)
35+
36+
set_target_properties(OMSimulator_external PROPERTIES EXCLUDE_FROM_ALL TRUE)
37+
38+
39+
add_library(libOMSimulator SHARED IMPORTED)
40+
set_target_properties(libOMSimulator PROPERTIES
41+
IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/OMSimulator/lib/x86_64-linux-gnu/omc/libOMSimulator.so
42+
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/OMSimulator/src/OMSimulatorLib
43+
)
44+
45+
add_dependencies(libOMSimulator OMSimulator_external)
2046

21-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/OMSimulator)
2247

48+
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/OMSimulator/
49+
DESTINATION ${CMAKE_INSTALL_PREFIX}
50+
USE_SOURCE_PERMISSIONS
51+
# Exclude the directories created by CMake's ExternalProject
52+
PATTERN src EXCLUDE
53+
PATTERN tmp EXCLUDE)

0 commit comments

Comments
 (0)