2017-08-12 06:17:24 -07:00
|
|
|
set(CMAKE_AUTORCC ON)
|
|
|
|
|
2017-08-20 14:36:33 -07:00
|
|
|
# generate c++ and rust code from fibonacci.json
|
2017-08-12 06:17:24 -07:00
|
|
|
add_custom_command(
|
2017-08-16 15:11:08 -07:00
|
|
|
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/rust/src/fibonacci_interface.rs"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/rust/src/fibonacci_types.rs"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/src/Fibonacci.h"
|
2017-08-13 03:47:53 -07:00
|
|
|
# if the cpp file is marked GENERATED, CMake will not check it for moc
|
|
|
|
# "${CMAKE_CURRENT_SOURCE_DIR}/src/tmp.cpp"
|
2017-08-16 15:11:08 -07:00
|
|
|
COMMAND ${CMAKE_BINARY_DIR}/rust_qt_binding_generator/rust_qt_binding_generator "${CMAKE_CURRENT_SOURCE_DIR}/fibonacci.json"
|
|
|
|
DEPENDS rust_qt_binding_generator fibonacci.json
|
2017-08-12 06:17:24 -07:00
|
|
|
)
|
|
|
|
|
2017-08-20 14:36:33 -07:00
|
|
|
# generate c++ and rust code from tree.json
|
2017-08-13 11:01:53 -07:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/rust/src/interface.rs"
|
2017-08-16 15:11:08 -07:00
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/rust/src/types.rs"
|
2017-08-13 11:01:53 -07:00
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/src/Tree.h"
|
|
|
|
# if the cpp file is marked GENERATED, CMake will not check it for moc
|
|
|
|
# "${CMAKE_CURRENT_SOURCE_DIR}/src/tmp.cpp"
|
|
|
|
COMMAND ${CMAKE_BINARY_DIR}/rust_qt_binding_generator/rust_qt_binding_generator "${CMAKE_CURRENT_SOURCE_DIR}/tree.json"
|
|
|
|
DEPENDS rust_qt_binding_generator tree.json
|
|
|
|
)
|
|
|
|
|
2017-08-20 14:36:33 -07:00
|
|
|
# compile the rust code into a static library
|
2017-08-12 06:17:24 -07:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/rust/${RUST_TARGET_DIR}/librust.a"
|
|
|
|
COMMAND cargo build ${RUST_BUILD_FLAG}
|
|
|
|
DEPENDS rust/src/lib.rs
|
2017-08-16 15:11:08 -07:00
|
|
|
rust/src/fibonacci_interface.rs
|
|
|
|
rust/src/fibonacci_implementation.rs
|
|
|
|
rust/src/fibonacci_types.rs
|
2017-08-12 06:17:24 -07:00
|
|
|
rust/src/implementation.rs
|
|
|
|
rust/src/interface.rs
|
|
|
|
rust/src/types.rs
|
|
|
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/rust"
|
|
|
|
)
|
|
|
|
add_custom_target(rust_target DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/rust/${RUST_TARGET_DIR}/librust.a")
|
|
|
|
|
2017-08-20 14:36:33 -07:00
|
|
|
if(Qt5Quick_FOUND)
|
|
|
|
add_definitions(-DQTQUICK)
|
|
|
|
set(Qt5Quick_LIBS Qt5::Quick)
|
|
|
|
endif()
|
2017-08-20 15:37:00 -07:00
|
|
|
if(Qt5QuickControls2_FOUND)
|
|
|
|
add_definitions(-DQTQUICKCONTROLS2)
|
|
|
|
set(Qt5QuickControls2_LIBS Qt5::QuickControls2)
|
|
|
|
endif()
|
2017-08-20 14:36:33 -07:00
|
|
|
|
2017-08-16 15:11:08 -07:00
|
|
|
set(Demo_SRCS src/main.cpp src/Tree.cpp src/Fibonacci.cpp
|
2017-08-12 06:17:24 -07:00
|
|
|
resource_file.qrc)
|
|
|
|
|
|
|
|
add_executable(Demo ${Demo_SRCS})
|
|
|
|
add_dependencies(Demo rust_target)
|
|
|
|
|
|
|
|
target_link_libraries(Demo
|
|
|
|
Qt5::Widgets
|
2017-08-20 15:37:00 -07:00
|
|
|
"${Qt5Quick_LIBS}"
|
2017-08-12 06:17:24 -07:00
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/rust/${RUST_TARGET_DIR}/librust.a"
|
|
|
|
)
|
|
|
|
|
|
|
|
set_target_properties(Demo PROPERTIES
|
|
|
|
CXX_STANDARD 11
|
|
|
|
CXX_STANDARD_REQUIRED ON
|
|
|
|
)
|