diff --git a/CMakeLists.txt b/CMakeLists.txt index d8814ac..f3413f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,13 +17,4 @@ src/I2sSimulationDataGenerator.cpp src/I2sSimulationDataGenerator.h ) -add_library(i2s_analyzer SHARED ${SOURCES}) -target_link_libraries(i2s_analyzer PRIVATE Saleae::AnalyzerSDK) - -if(MSVC) - install(TARGETS i2s_analyzer RUNTIME DESTINATION "Analyzers") -else() - install(TARGETS i2s_analyzer LIBRARY DESTINATION "Analyzers") -endif() - -set_post_build_destination(i2s_analyzer) +add_analyzer_plugin(i2s_analyzer SOURCES ${SOURCES}) diff --git a/cmake/ExternalAnalyzerSDK.cmake b/cmake/ExternalAnalyzerSDK.cmake index 6e32d65..094d544 100644 --- a/cmake/ExternalAnalyzerSDK.cmake +++ b/cmake/ExternalAnalyzerSDK.cmake @@ -38,11 +38,20 @@ if(NOT TARGET Saleae::AnalyzerSDK) endif() endif() -# Optionally copy the compiled library after build to ${POST_BUILD_DESTINATION}, if POST_BUILD_DESTINATION is defined. -macro(set_post_build_destination target_name) - if(DEFINED POST_BUILD_DESTINATION) - add_custom_command(TARGET ${target_name} - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy $ ${POST_BUILD_DESTINATION}) - endif() -endmacro() +function(add_analyzer_plugin TARGET) + set(options ) + set(single_value_args ) + set(multi_value_args SOURCES) + cmake_parse_arguments( _p "${options}" "${single_value_args}" "${multi_value_args}" ${ARGN} ) + + + add_library(${TARGET} MODULE ${_p_SOURCES}) + target_link_libraries(${TARGET} PRIVATE Saleae::AnalyzerSDK) + + set(ANALYZER_DESTINATION "Analyzers") + install(TARGETS ${TARGET} RUNTIME DESTINATION ${ANALYZER_DESTINATION} + LIBRARY DESTINATION ${ANALYZER_DESTINATION}) + + set_target_properties(${TARGET} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${ANALYZER_DESTINATION} + LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${ANALYZER_DESTINATION}) +endfunction() \ No newline at end of file diff --git a/src/I2sAnalyzer.h b/src/I2sAnalyzer.h index d708262..624f501 100644 --- a/src/I2sAnalyzer.h +++ b/src/I2sAnalyzer.h @@ -6,7 +6,7 @@ #include "I2sSimulationDataGenerator.h" class I2sAnalyzerSettings; -class ANALYZER_EXPORT I2sAnalyzer : public Analyzer2 +class I2sAnalyzer : public Analyzer2 { public: I2sAnalyzer();