diff --git a/wpimath/CMakeLists.txt b/wpimath/CMakeLists.txt index 4f0e8da17a0..8855f697e8a 100644 --- a/wpimath/CMakeLists.txt +++ b/wpimath/CMakeLists.txt @@ -5,6 +5,18 @@ include(CompileWarnings) include(AddTest) include(DownloadAndCheck) +# workaround for makefiles - for some reason parent directories aren't created. +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/protobuf") +file(GLOB wpimath_proto_src src/main/proto/*.proto) +protobuf_generate_cpp( + WPIMATH_PROTO_SRCS + WPIMATH_PROTO_HDRS + PROTOC_OUT_DIR + "${CMAKE_CURRENT_BINARY_DIR}/protobuf" + PROTOS + ${wpimath_proto_src} +) + function(quickbuf_generate SRCS JAVA_PACKAGE) if(NOT ARGN) message(SEND_ERROR "Error: PROTOBUF_GENERATE_QUICKBUF() called without any proto files") @@ -190,29 +202,11 @@ endif() file(GLOB_RECURSE wpimath_native_src src/main/native/cpp/*.cpp) list(REMOVE_ITEM wpimath_native_src ${wpimath_jni_src}) -file(GLOB wpimath_proto_src src/main/proto/*.proto) - set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS FALSE) -add_library(wpimath ${wpimath_native_src} ${wpimath_proto_src}) +add_library(wpimath ${wpimath_native_src} ${WPIMATH_PROTO_SRCS}) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) set_target_properties(wpimath PROPERTIES DEBUG_POSTFIX "d") -if(MSVC) - set(export_macro "__declspec(dllexport)") -endif() -protobuf_generate( - TARGET - wpimath - EXPORT_MACRO - ${export_macro} - OUT_VAR - protobuf_generated_srcs - PROTOC_OUT_DIR - "${CMAKE_CURRENT_BINARY_DIR}/protobuf" - APPEND_PATH -) -target_sources(wpimath PUBLIC ${protobuf_generated_srcs}) - add_custom_command( TARGET wpimath PRE_LINK