41 lines
1.5 KiB
CMake
41 lines
1.5 KiB
CMake
cmake_minimum_required(VERSION 3.20)
|
|
project(lv_cpp_demo LANGUAGES CXX)
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
if(NOT WIN32)
|
|
message(FATAL_ERROR "This sample builds a Windows DLL for LabVIEW.")
|
|
endif()
|
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
message(WARNING "This is a 64-bit build. 32-bit LabVIEW needs a Win32 build.")
|
|
endif()
|
|
set(dir ${CMAKE_SOURCE_DIR}/src)
|
|
file(GLOB_RECURSE srcs "${dir}/*.cpp" "${dir}/*.c" "${dir}/*.h")
|
|
add_library(lv_cpp_demo SHARED ${srcs})
|
|
target_compile_definitions(lv_cpp_demo PRIVATE LV_CPP_DEMO_BUILD)
|
|
set_target_properties(lv_cpp_demo PROPERTIES OUTPUT_NAME lv_cpp_demo)
|
|
if(MSVC)
|
|
target_compile_options(lv_cpp_demo PUBLIC /utf-8)
|
|
set(dumpbin "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/dumpbin.exe")
|
|
add_custom_target(dump_exports
|
|
COMMAND "${dumpbin}" /exports "$<TARGET_FILE:lv_cpp_demo>"
|
|
DEPENDS lv_cpp_demo
|
|
USES_TERMINAL
|
|
)
|
|
add_dependencies(dump_exports lv_cpp_demo)
|
|
endif()
|
|
|
|
|
|
|
|
add_executable(lv_cpp_demo_test test/main.cpp)
|
|
target_link_libraries(lv_cpp_demo_test PRIVATE lv_cpp_demo)
|
|
|
|
|
|
|
|
set(labview_dir "${CMAKE_CURRENT_SOURCE_DIR}/labview")
|
|
add_custom_command(TARGET lv_cpp_demo POST_BUILD
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory "${labview_dir}"
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:lv_cpp_demo>" "${labview_dir}/$<TARGET_FILE_NAME:lv_cpp_demo>"
|
|
VERBATIM
|
|
)
|
|
|