@@ -3,38 +3,40 @@ project(lslexamples
33 LANGUAGES C CXX
44 VERSION 0.2.0)
55
6- include (GNUInstallDirs )
6+ if (PROJECT_IS_TOP_LEVEL)
7+ include (GNUInstallDirs )
78
8- set (LSL_SEARCH_PATHS
9- ${LSL_INSTALL_ROOT}
10- "${CMAKE_CURRENT_LIST_DIR } /../install" # GHA scripts default install directory
11- "${CMAKE_CURRENT_LIST_DIR } /../cmake-build-release/install" # CLion default if using -DCMAKE_INSTALL_PREFIX=install
12- )
13- if (APPLE )
14- # Also search in a Frameworks subdirectory for each path
15- foreach (p IN LISTS LSL_SEARCH_PATHS)
16- if (p)
17- list (APPEND LSL_SEARCH_PATHS "${p} /Frameworks" )
18- endif ()
19- endforeach ()
20- else ()
21- # Add MSVC-specific paths if not on Apple
22- list (APPEND LSL_SEARCH_PATHS
23- "${CMAKE_CURRENT_LIST_DIR } /../cmake-build-release-visual-studio/install" # CLion default if using VS compiler
24- "${CMAKE_CURRENT_LIST_DIR } /../out/build/x64-Release/install" # MSVC default if using -DCMAKE_INSTALL_PREFIX=install
9+ set (LSL_SEARCH_PATHS
10+ ${LSL_INSTALL_ROOT}
11+ "${CMAKE_CURRENT_LIST_DIR } /../install" # GHA scripts default install directory
12+ "${CMAKE_CURRENT_LIST_DIR } /../cmake-build-release/install" # CLion default if using -DCMAKE_INSTALL_PREFIX=install
2513 )
26- endif ()
14+ if (APPLE )
15+ # Also search in a Frameworks subdirectory for each path
16+ foreach (p IN LISTS LSL_SEARCH_PATHS)
17+ if (p)
18+ list (APPEND LSL_SEARCH_PATHS "${p} /Frameworks" )
19+ endif ()
20+ endforeach ()
21+ else ()
22+ # Add MSVC-specific paths if not on Apple
23+ list (APPEND LSL_SEARCH_PATHS
24+ "${CMAKE_CURRENT_LIST_DIR } /../cmake-build-release-visual-studio/install" # CLion default if using VS compiler
25+ "${CMAKE_CURRENT_LIST_DIR } /../out/build/x64-Release/install" # MSVC default if using -DCMAKE_INSTALL_PREFIX=install
26+ )
27+ endif ()
2728
28- find_package (LSL REQUIRED
29- HINTS ${LSL_SEARCH_PATHS}
30- PATH_SUFFIXES share/LSL
31- )
32- get_filename_component (LSL_PATH ${LSL_CONFIG} DIRECTORY )
33- message (STATUS "Found LSL lib in ${LSL_PATH} " )
29+ find_package (LSL REQUIRED
30+ HINTS ${LSL_SEARCH_PATHS}
31+ PATH_SUFFIXES share/LSL
32+ )
33+ get_filename_component (LSL_PATH ${LSL_CONFIG} DIRECTORY )
34+ message (STATUS "Found LSL lib in ${LSL_PATH} " )
3435
35- # Include the LSLCMake.cmake file, just for testing.
36- # This doesn't do much for us now that we don't use installLSLApp() anymore.
37- include ("${LSL_PATH} /LSLCMake.cmake" )
36+ # Include the LSLCMake.cmake file, just for testing.
37+ # This doesn't do much for us now that we don't use installLSLApp() anymore.
38+ include ("${LSL_PATH} /LSLCMake.cmake" )
39+ endif ()
3840
3941# convenience function to add an example file
4042# this creates a target, links the necessary libraries and
@@ -65,10 +67,12 @@ function(addlslexample name extension)
6567# )
6668# endif()
6769
68- install (TARGETS ${name}
69- COMPONENT ${PROJECT_NAME }
70- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
71- )
70+ if (PROJECT_IS_TOP_LEVEL)
71+ install (TARGETS ${name}
72+ COMPONENT ${PROJECT_NAME }
73+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
74+ )
75+ endif ()
7276endfunction ()
7377
7478find_package (Threads )
@@ -107,9 +111,12 @@ if(WIN32)
107111 $<TARGET_FILE_DIR :HandleMetaData >
108112 COMMENT "Copying lsl.dll to examples build directory"
109113 )
110- # Install the lsl.dll to the same directory as the executable.
111- install (
112- CODE "file(INSTALL DESTINATION \" ${CMAKE_INSTALL_PREFIX } /${CMAKE_INSTALL_BINDIR} \" TYPE SHARED_LIBRARY FILES \" $<TARGET_FILE :LSL ::lsl >\" )"
113- COMPONENT ${PROJECT_NAME }
114- )
114+
115+ if (PROJECT_IS_TOP_LEVEL)
116+ # Install the lsl.dll to the same directory as the executable.
117+ install (
118+ CODE "file(INSTALL DESTINATION \" ${CMAKE_INSTALL_PREFIX } /${CMAKE_INSTALL_BINDIR} \" TYPE SHARED_LIBRARY FILES \" $<TARGET_FILE :LSL ::lsl >\" )"
119+ COMPONENT ${PROJECT_NAME }
120+ )
121+ endif ()
115122endif ()
0 commit comments