@@ -29,13 +29,7 @@ set(MATRIX_SOURCES ${MATRIX_CORE_SOURCES})
29
29
if (ENABLE_EMULATOR)
30
30
# Add emulator source
31
31
list (APPEND MATRIX_SOURCES lib/emulator.cc)
32
-
33
- # Find SDL2 for the emulator
34
- find_package (SDL2 REQUIRED)
35
-
36
- # Define preprocessor macro to indicate emulator is enabled
37
- add_compile_definitions (ENABLE_EMULATOR)
38
-
32
+
39
33
message (STATUS "Building with emulator support" )
40
34
else ()
41
35
message (STATUS "Building without emulator support" )
@@ -49,11 +43,20 @@ target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14)
49
43
# Include directories
50
44
target_include_directories (${PROJECT_NAME}
51
45
PRIVATE
52
- # where the library itself will look for its internal headers
53
- ${CMAKE_CURRENT_SOURCE_DIR} /lib
46
+ # where the library itself will look for its internal headers
47
+ ${CMAKE_CURRENT_SOURCE_DIR} /lib
54
48
PUBLIC
55
- # where top-level project will look for the library's public headers
56
- $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /include >
57
- # where external projects will look for the library's public headers
58
- $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR} >
49
+ # where top-level project will look for the library's public headers
50
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /include >
51
+ # where external projects will look for the library's public headers
52
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR} >
59
53
)
54
+
55
+ # Export ENABLE_EMULATOR define to consumers of the library
56
+ if (ENABLE_EMULATOR)
57
+ target_compile_definitions (${PROJECT_NAME} PUBLIC ENABLE_EMULATOR)
58
+
59
+ # Find SDL2 for the emulator
60
+ find_package (SDL2 REQUIRED)
61
+ target_link_libraries (${PROJECT_NAME} PRIVATE SDL2)
62
+ endif ()
0 commit comments