diff options
author | Matthias Vogelgesang <matthias.vogelgesang@gmail.com> | 2012-06-12 10:21:55 +0200 |
---|---|---|
committer | Matthias Vogelgesang <matthias.vogelgesang@gmail.com> | 2012-06-12 10:21:55 +0200 |
commit | 580dae2183e27ccec00f127b85188df143f49c54 (patch) | |
tree | 35e43a1587a8b624218006e2e41d73c28dd1b160 /src/CMakeLists.txt | |
parent | 733da14c66d347bb2ae452766a36bf3c1381cacd (diff) | |
download | uca-580dae2183e27ccec00f127b85188df143f49c54.tar.gz uca-580dae2183e27ccec00f127b85188df143f49c54.tar.bz2 uca-580dae2183e27ccec00f127b85188df143f49c54.tar.xz uca-580dae2183e27ccec00f127b85188df143f49c54.zip |
Generate enum types from source
It became a little unwieldy to create the enum types manually via
g_enums_register_static(). This changeset creates the types from enum
definitions in public headers using glib2-mkenum.
Be sure to include uca-enums.h in every source file that needs to know GObject
enum type.
Diffstat (limited to 'src/CMakeLists.txt')
-rw-r--r-- | src/CMakeLists.txt | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 73d1034..e9d5ebc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -24,7 +24,7 @@ find_package(ClSerMe4) # --- Miscellanous packages find_package(PkgConfig) - +find_program(GLIB2_MKENUMS glib-mkenums REQUIRED) pkg_check_modules(GLIB2 glib-2.0>=2.24 REQUIRED) pkg_check_modules(GOBJECT2 gobject-2.0>=2.24 REQUIRED) @@ -96,6 +96,28 @@ if (HAVE_MOCK_CAMERA) list(APPEND cameras "Mock") endif() +# --- Generate enum file +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/uca-enums.h + COMMAND ${GLIB2_MKENUMS} + ARGS + --template uca-enums.h.template + ${uca_HDRS} > ${CMAKE_CURRENT_BINARY_DIR}/uca-enums.h + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DEPENDS ${uca_HDRS} + ${CMAKE_CURRENT_SOURCE_DIR}/uca-enums.h.template) + +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/uca-enums.c + COMMAND ${GLIB2_MKENUMS} + ARGS + --template uca-enums.c.template + ${uca_HDRS} > ${CMAKE_CURRENT_BINARY_DIR}/uca-enums.c + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DEPENDS ${uca_HDRS} + ${CMAKE_CURRENT_BINARY_DIR}/uca-enums.h + ${CMAKE_CURRENT_SOURCE_DIR}/uca-enums.c.template + ) # --- Configure step configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in @@ -111,7 +133,9 @@ include_directories( # --- Build target ------------------------------------------------------------ add_definitions("-std=c99 -Wall") -add_library(uca SHARED ${uca_SRCS}) +add_library(uca SHARED + ${uca_SRCS} + ${CMAKE_CURRENT_BINARY_DIR}/uca-enums.c) set_target_properties(uca PROPERTIES VERSION ${UCA_ABI_VERSION} |