@@ -25,7 +25,7 @@ set(LSL_WINVER "0x0601" CACHE STRING
2525 "Windows version (_WIN32_WINNT) to target (defaults to 0x0601 for Windows 7)" )
2626
2727# Add an object library so all files are only compiled once
28- set (lslobj_sources
28+ add_library (lslobj OBJECT
2929 src/api_config.cpp
3030 src/api_config.h
3131 src/api_types.hpp
@@ -96,7 +96,6 @@ set(lslobj_sources
9696 include /lsl/types.h
9797 include /lsl/xml.h
9898)
99- add_library (lslobj OBJECT ${lslobj_sources} )
10099
101100# try to find out which revision is currently checked out
102101find_package (Git)
@@ -120,11 +119,9 @@ else()
120119 set (lslgitrevision "unknown" )
121120 set (lslgitbranch "unknown" )
122121endif ()
123- set (LSL_VERSION_INFO "\" git:${lslgitrevision} /branch:${lslgitbranch} /build:${CMAKE_BUILD_TYPE} /compiler:${CMAKE_CXX_COMPILER_ID} -${CMAKE_CXX_COMPILER_VERSION} /boost:\" BOOST_LIB_VERSION" )
124- set_source_files_properties ("src/common.cpp" PROPERTIES COMPILE_DEFINITIONS LSL_LIBRARY_INFO_STR=${LSL_VERSION_INFO} )
122+ set (LSL_VERSION_INFO "git:${lslgitrevision} /branch:${lslgitbranch} /build:${CMAKE_BUILD_TYPE} /compiler:${CMAKE_CXX_COMPILER_ID} -${CMAKE_CXX_COMPILER_VERSION} " )
125123set_source_files_properties ("src/loguru/loguru.cpp" PROPERTIES COMPILE_DEFINITIONS LOGURU_STACKTRACES=$<BOOL :${LSL_DEBUGLOG} >)
126124
127-
128125## create the lslboost target
129126add_library (lslboost OBJECT
130127 lslboost/asio_objects.cpp
@@ -139,7 +136,7 @@ if (UNIX)
139136 )
140137 find_package (Threads REQUIRED)
141138 target_link_libraries (lslboost PUBLIC Threads::Threads)
142- target_compile_features (lslboost PUBLIC cxx_std_11)
139+ target_compile_features (lslboost PUBLIC cxx_std_11 cxx_lambda_init_captures )
143140else () # WIN32
144141 target_sources (lslboost PRIVATE
145142 lslboost/libs/serialization/src/codecvt_null.cpp
@@ -165,7 +162,12 @@ target_include_directories(lslboost PUBLIC
165162 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /lslboost>)
166163
167164
168- target_link_libraries (lslobj PRIVATE lslboost)
165+ target_link_libraries (lslobj
166+ PRIVATE
167+ lslboost
168+ PUBLIC
169+ $<$<AND :$<BOOL :${LSL_DEBUGLOG} >,$<PLATFORM_ID:Linux>>:dl>
170+ )
169171target_include_directories (lslobj
170172 PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR} /include >
171173)
@@ -176,37 +178,24 @@ target_compile_definitions(lslobj
176178)
177179
178180# shared library
179- if (CMAKE_GENERATOR MATCHES "Xcode" )
180- # Xcode is rather annoying in that it doesn't build SHARED libs unless they have source files.
181- # So we need to build from source, and then add all the other settings missing due to lack of lslobj
182- add_library (lsl SHARED ${lslobj_sources} )
183- target_link_libraries (lsl PRIVATE lslboost)
184- else ()
185- add_library (lsl SHARED)
186- target_link_libraries (lsl
187- PUBLIC lslobj
188- PRIVATE lslboost)
189- endif ()
190- target_include_directories (lsl
191- PUBLIC
192- $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR} /include >
193- $<INSTALL_INTERFACE:include >
194- )
195- target_compile_definitions (lsl
196- PRIVATE LIBLSL_EXPORTS $<$<PLATFORM_ID:Windows>:_CRT_SECURE_NO_WARNINGS>
197- INTERFACE LSLNOAUTOLINK # don't use #pragma(lib) in CMake builds
198- )
199-
181+ add_library (lsl SHARED src/buildinfo.cpp)
182+ target_compile_definitions (lsl PRIVATE
183+ LSL_LIBRARY_INFO_STR="${LSL_VERSION_INFO} /link:shared"
184+ LIBLSL_EXPORTS)
185+ target_link_libraries (lsl
186+ PUBLIC lslobj
187+ PRIVATE lslboost)
200188set_target_properties (lsl PROPERTIES
201189 VERSION ${liblsl_VERSION_MAJOR} .${liblsl_VERSION_MINOR} .${liblsl_VERSION_PATCH}
202190)
203191
204192set (LSL_EXPORT_TARGETS lsl lslobj lslboost)
205193if (LSL_BUILD_STATIC)
206- add_library (lsl-static STATIC )
194+ add_library (lsl-static STATIC src/buildinfo.cpp)
195+ target_compile_definitions (lsl-static PRIVATE LSL_LIBRARY_INFO_STR="${LSL_VERSION_INFO} /link:static" )
207196 target_link_libraries (lsl-static PUBLIC lslobj PRIVATE lslboost)
208197 # for LSL_CPP_API export header
209- target_compile_definitions (lsl-static INTERFACE LIBLSL_STATIC)
198+ target_compile_definitions (lsl-static PUBLIC LIBLSL_STATIC)
210199endif ()
211200
212201if (LSL_FORCE_FANCY_LIBNAME)
0 commit comments