@@ -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
@@ -176,37 +173,24 @@ target_compile_definitions(lslobj
176173)
177174
178175# 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-
176+ add_library (lsl SHARED src/buildinfo.cpp)
177+ target_compile_definitions (lsl PRIVATE
178+ LSL_LIBRARY_INFO_STR="${LSL_VERSION_INFO} /link:shared"
179+ LIBLSL_EXPORTS)
180+ target_link_libraries (lsl
181+ PUBLIC lslobj
182+ PRIVATE lslboost)
200183set_target_properties (lsl PROPERTIES
201184 VERSION ${liblsl_VERSION_MAJOR} .${liblsl_VERSION_MINOR} .${liblsl_VERSION_PATCH}
202185)
203186
204187set (LSL_EXPORT_TARGETS lsl lslobj lslboost)
205188if (LSL_BUILD_STATIC)
206- add_library (lsl-static STATIC )
189+ add_library (lsl-static STATIC src/buildinfo.cpp)
190+ target_compile_definitions (lsl-static PRIVATE LSL_LIBRARY_INFO_STR="${LSL_VERSION_INFO} /link:static" )
207191 target_link_libraries (lsl-static PUBLIC lslobj PRIVATE lslboost)
208192 # for LSL_CPP_API export header
209- target_compile_definitions (lsl-static INTERFACE LIBLSL_STATIC)
193+ target_compile_definitions (lsl-static PUBLIC LIBLSL_STATIC)
210194endif ()
211195
212196if (LSL_FORCE_FANCY_LIBNAME)
0 commit comments