diff options
author | Aaron Seigo <aseigo@kde.org> | 2014-11-30 13:51:21 +0100 |
---|---|---|
committer | Aaron Seigo <aseigo@kde.org> | 2014-11-30 13:51:21 +0100 |
commit | b49cead47537d8d1d2c78cb4596bb828fd94b347 (patch) | |
tree | 1bb531f7d856269bb734c5a5eeeea473b375fe64 | |
parent | 97b79eeb86eedee57630b8d29f6eeab08ccb02b0 (diff) | |
download | sink-b49cead47537d8d1d2c78cb4596bb828fd94b347.tar.gz sink-b49cead47537d8d1d2c78cb4596bb828fd94b347.zip |
create a common lib, autogen the buffer classes there dynamically
simplifies the generate_buffers function a bit.
only missing part now: get the binaries to rebuild when the buffer
class is updated. apparently this doesn't cause the common library
to rebuild and so the client and resource binaries don't know they
need to rebuild automatically. but at least the _generated.h files
are now dynamically created. huzzah for that.
-rw-r--r-- | CMakeLists.txt | 10 | ||||
-rw-r--r-- | client/CMakeLists.txt | 5 | ||||
-rw-r--r-- | common/CMakeLists.txt | 10 | ||||
-rw-r--r-- | common/commands/CMakeLists.txt | 1 | ||||
-rw-r--r-- | resource/CMakeLists.txt | 4 |
5 files changed, 19 insertions, 11 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 91c4568..09c6a1e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -20,10 +20,14 @@ include(ECMPackageConfigHelpers) | |||
20 | 20 | ||
21 | find_package(Qt5Core REQUIRED) | 21 | find_package(Qt5Core REQUIRED) |
22 | find_package(FlatBuffers REQUIRED) | 22 | find_package(FlatBuffers REQUIRED) |
23 | function(generate_flatbuffers dest) | 23 | function(generate_flatbuffers) |
24 | # TODO: move the file from ${fbs}_generated.h to just ${fbs}? | ||
25 | foreach(fbs ${ARGN}) | 24 | foreach(fbs ${ARGN}) |
26 | execute_process(COMMAND ${FLATBUFFERS_FLATC_EXECUTABLE} -c -b --gen-includes -o ${dest} ${CMAKE_CURRENT_SOURCE_DIR}/${fbs}) | 25 | message("making ${CMAKE_CURRENT_BINARY_DIR}/${fbs}_generated.h from ${CMAKE_CURRENT_SOURCE_DIR}/${fbs}.fbs") |
26 | add_custom_command( | ||
27 | OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${fbs}_generated.h | ||
28 | COMMAND ${FLATBUFFERS_FLATC_EXECUTABLE} -c -b --gen-includes -o ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${fbs}.fbs | ||
29 | DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${fbs}.fbs | ||
30 | ) | ||
27 | endforeach(fbs) | 31 | endforeach(fbs) |
28 | endfunction(generate_flatbuffers) | 32 | endfunction(generate_flatbuffers) |
29 | 33 | ||
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 186e3fe..859f707 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt | |||
@@ -2,13 +2,12 @@ project(toynadi_client) | |||
2 | 2 | ||
3 | include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) | 3 | include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) |
4 | 4 | ||
5 | set(common_path "../common/") | ||
6 | |||
7 | set(toynadiclient_SRCS | 5 | set(toynadiclient_SRCS |
8 | ${common_path}/console.cpp | ||
9 | main.cpp | 6 | main.cpp |
10 | resourceaccess.cpp | 7 | resourceaccess.cpp |
11 | ) | 8 | ) |
9 | |||
12 | add_executable(${PROJECT_NAME} ${toynadiclient_SRCS}) | 10 | add_executable(${PROJECT_NAME} ${toynadiclient_SRCS}) |
11 | target_link_libraries(${PROJECT_NAME} toynadicommon) | ||
13 | qt5_use_modules(${PROJECT_NAME} Widgets Network) | 12 | qt5_use_modules(${PROJECT_NAME} Widgets Network) |
14 | install(TARGETS ${PROJECT_NAME} DESTINATION bin) | 13 | install(TARGETS ${PROJECT_NAME} DESTINATION bin) |
diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 2ceacf8..32e10f6 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt | |||
@@ -1 +1,9 @@ | |||
1 | add_subdirectory(commands) | 1 | project(toynadicommon) |
2 | generate_flatbuffers(commands/handshake) | ||
3 | |||
4 | set(command_SRCS | ||
5 | console.cpp | ||
6 | ${CMAKE_CURRENT_BINARY_DIR}/commands/handshake_generated.h) | ||
7 | |||
8 | add_library(${PROJECT_NAME} ${command_SRCS}) | ||
9 | qt5_use_modules(${PROJECT_NAME} Widgets) | ||
diff --git a/common/commands/CMakeLists.txt b/common/commands/CMakeLists.txt deleted file mode 100644 index 2a9ba64..0000000 --- a/common/commands/CMakeLists.txt +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | generate_flatbuffers(${CMAKE_CURRENT_BINARY_DIR} handshake.fbs) | ||
diff --git a/resource/CMakeLists.txt b/resource/CMakeLists.txt index 3de51b5..d74c705 100644 --- a/resource/CMakeLists.txt +++ b/resource/CMakeLists.txt | |||
@@ -2,14 +2,12 @@ project(toynadi_resource) | |||
2 | 2 | ||
3 | include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) | 3 | include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) |
4 | 4 | ||
5 | set(common_path "../common/") | ||
6 | |||
7 | set(toynadiresource_SRCS | 5 | set(toynadiresource_SRCS |
8 | ${common_path}/console.cpp | ||
9 | main.cpp | 6 | main.cpp |
10 | listener.cpp | 7 | listener.cpp |
11 | ) | 8 | ) |
12 | 9 | ||
13 | add_executable(${PROJECT_NAME} ${toynadiresource_SRCS}) | 10 | add_executable(${PROJECT_NAME} ${toynadiresource_SRCS}) |
11 | target_link_libraries(${PROJECT_NAME} toynadicommon) | ||
14 | qt5_use_modules(${PROJECT_NAME} Widgets Network) | 12 | qt5_use_modules(${PROJECT_NAME} Widgets Network) |
15 | install(TARGETS ${PROJECT_NAME} DESTINATION bin) | 13 | install(TARGETS ${PROJECT_NAME} DESTINATION bin) |