From cd6b904e970291a63551d0f1d80bbd550e778ec8 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Sat, 11 Mar 2017 23:20:25 +0100 Subject: [PATCH] CMake: merge created header+vapi files into a single directory --- CMakeLists.txt | 3 ++- cmake/UseVala.cmake | 24 +++++++++++++++--------- gpgme-vala/CMakeLists.txt | 20 +++++++++++++++----- libdino/CMakeLists.txt | 12 ++++++------ main/CMakeLists.txt | 10 +++++----- qlite/CMakeLists.txt | 5 ++--- xmpp-vala/CMakeLists.txt | 9 ++++----- 7 files changed, 49 insertions(+), 34 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index aff736fa..def9f8d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,8 @@ endif() set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) -set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") +set (GLOBAL_DEBUG_FLAGS -g) +set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GLOBAL_DEBUG_FLAGS}") set (VALA_CFLAGS -Wno-deprecated-declarations -Wno-incompatible-pointer-types -Wno-int-conversion -Wno-discarded-qualifiers) add_subdirectory(gpgme-vala) diff --git a/cmake/UseVala.cmake b/cmake/UseVala.cmake index ae090bb1..2ba01ee7 100644 --- a/cmake/UseVala.cmake +++ b/cmake/UseVala.cmake @@ -115,7 +115,7 @@ function(_vala_mkdir_for_file file) endfunction() function(vala_precompile output) - cmake_parse_arguments(ARGS "FAST_VAPI" "DIRECTORY;GENERATE_HEADER;GENERATE_VAPI" + cmake_parse_arguments(ARGS "FAST_VAPI" "DIRECTORY;GENERATE_HEADER;GENERATE_VAPI;EXPORTS_DIR" "SOURCES;PACKAGES;OPTIONS;DEFINITIONS;CUSTOM_VAPIS;GRESOURCES" ${ARGN}) set(ARGS_FAST_VAPI true) @@ -125,7 +125,13 @@ function(vala_precompile output) else(ARGS_DIRECTORY) set(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) endif(ARGS_DIRECTORY) - include_directories(${DIRECTORY}) + if(ARGS_EXPORTS_DIR) + set(ARGS_EXPORTS_DIR ${CMAKE_BINARY_DIR}/${ARGS_EXPORTS_DIR}) + else(ARGS_EXPORTS_DIR) + set(ARGS_EXPORTS_DIR ${CMAKE_BINARY_DIR}/exports) + endif(ARGS_EXPORTS_DIR) + file(MAKE_DIRECTORY "${ARGS_EXPORTS_DIR}") + include_directories(${DIRECTORY} ${ARGS_EXPORTS_DIR}) set(vala_pkg_opts "") foreach(pkg ${ARGS_PACKAGES}) @@ -160,9 +166,9 @@ function(vala_precompile output) set(vapi_arguments "") if(ARGS_GENERATE_VAPI) - list(APPEND out_extra_files "${DIRECTORY}/${ARGS_GENERATE_VAPI}.vapi") - list(APPEND out_extra_files "${DIRECTORY}/${ARGS_GENERATE_VAPI}-internal.vapi") - set(vapi_arguments "--vapi=${ARGS_GENERATE_VAPI}.vapi" "--internal-vapi=${ARGS_GENERATE_VAPI}-internal.vapi") + list(APPEND out_extra_files "${ARGS_EXPORTS_DIR}/${ARGS_GENERATE_VAPI}.vapi") + list(APPEND out_extra_files "${ARGS_EXPORTS_DIR}/${ARGS_GENERATE_VAPI}_internal.vapi") + set(vapi_arguments "--vapi=${ARGS_EXPORTS_DIR}/${ARGS_GENERATE_VAPI}.vapi" "--internal-vapi=${ARGS_EXPORTS_DIR}/${ARGS_GENERATE_VAPI}_internal.vapi") # Header and internal header is needed to generate internal vapi if (NOT ARGS_GENERATE_HEADER) @@ -172,10 +178,10 @@ function(vala_precompile output) set(header_arguments "") if(ARGS_GENERATE_HEADER) - list(APPEND out_extra_files "${DIRECTORY}/${ARGS_GENERATE_HEADER}.h") - list(APPEND out_extra_files "${DIRECTORY}/${ARGS_GENERATE_HEADER}_internal.h") - list(APPEND header_arguments "--header=${DIRECTORY}/${ARGS_GENERATE_HEADER}.h") - list(APPEND header_arguments "--internal-header=${DIRECTORY}/${ARGS_GENERATE_HEADER}_internal.h") + list(APPEND out_extra_files "${ARGS_EXPORTS_DIR}/${ARGS_GENERATE_HEADER}.h") + list(APPEND out_extra_files "${ARGS_EXPORTS_DIR}/${ARGS_GENERATE_HEADER}_internal.h") + list(APPEND header_arguments "--header=${ARGS_EXPORTS_DIR}/${ARGS_GENERATE_HEADER}.h") + list(APPEND header_arguments "--internal-header=${ARGS_EXPORTS_DIR}/${ARGS_GENERATE_HEADER}_internal.h") endif(ARGS_GENERATE_HEADER) if(ARGS_FAST_VAPI) diff --git a/gpgme-vala/CMakeLists.txt b/gpgme-vala/CMakeLists.txt index a510d293..98f6e72d 100644 --- a/gpgme-vala/CMakeLists.txt +++ b/gpgme-vala/CMakeLists.txt @@ -24,7 +24,7 @@ GENERATE_VAPI GENERATE_HEADER gpgme-vala OPTIONS - -g + ${GLOBAL_DEBUG_FLAGS} --thread ) @@ -33,16 +33,26 @@ add_definitions(${CFLAGS}) add_library(gpgme-vala SHARED ${GPGME_VALA_C} src/gpgme_fix.c) target_link_libraries(gpgme-vala ${GPGME_VALA_LIBRARIES} ${GPGME_LIBRARIES}) -add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/gpgme-vala/gpgme.vapi +add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/exports/gpgme_fix.h" COMMAND - cat "${CMAKE_BINARY_DIR}/gpgme-vala/gpgme-vala.vapi" "${CMAKE_CURRENT_SOURCE_DIR}/vapi/gpgme_public.vapi" > "${CMAKE_BINARY_DIR}/gpgme-vala/gpgme.vapi" + cp "${CMAKE_CURRENT_SOURCE_DIR}/src/gpgme_fix.h" "${CMAKE_BINARY_DIR}/exports/gpgme_fix.h" DEPENDS - ${CMAKE_BINARY_DIR}/gpgme-vala/gpgme-vala.vapi + "${CMAKE_CURRENT_SOURCE_DIR}/src/gpgme_fix.h" +COMMENT + Copy header file gpgme_fix.h +) + +add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/exports/gpgme.vapi +COMMAND + cat "${CMAKE_BINARY_DIR}/exports/gpgme-vala.vapi" "${CMAKE_CURRENT_SOURCE_DIR}/vapi/gpgme_public.vapi" > "${CMAKE_BINARY_DIR}/exports/gpgme.vapi" +DEPENDS + ${CMAKE_BINARY_DIR}/exports/gpgme-vala.vapi ${CMAKE_CURRENT_SOURCE_DIR}/vapi/gpgme_public.vapi ) add_custom_target(gpgme-vapi DEPENDS - ${CMAKE_BINARY_DIR}/gpgme-vala/gpgme.vapi + ${CMAKE_BINARY_DIR}/exports/gpgme_fix.h + ${CMAKE_BINARY_DIR}/exports/gpgme.vapi ) diff --git a/libdino/CMakeLists.txt b/libdino/CMakeLists.txt index e638b3c8..ece8a56f 100644 --- a/libdino/CMakeLists.txt +++ b/libdino/CMakeLists.txt @@ -129,9 +129,9 @@ SOURCES src/ui/unified_window.vala src/ui/util.vala CUSTOM_VAPIS - "${CMAKE_BINARY_DIR}/xmpp-vala/xmpp-vala.vapi" - "${CMAKE_BINARY_DIR}/qlite/qlite.vapi" - "${CMAKE_BINARY_DIR}/gpgme-vala/gpgme.vapi" + "${CMAKE_BINARY_DIR}/exports/xmpp-vala.vapi" + "${CMAKE_BINARY_DIR}/exports/qlite.vapi" + "${CMAKE_BINARY_DIR}/exports/gpgme.vapi" PACKAGES ${LIBDINO_PACKAGES} GENERATE_VAPI @@ -142,11 +142,11 @@ GRESOURCES ${LIBDINO_GRESOURCES_XML} OPTIONS --target-glib=2.38 - -g + ${GLOBAL_DEBUG_FLAGS} --thread ) -set(CFLAGS ${VALA_CFLAGS} ${LIBDINO_CFLAGS} -I${CMAKE_BINARY_DIR}/xmpp-vala -I${CMAKE_BINARY_DIR}/qlite -I${CMAKE_BINARY_DIR}/gpgme-vala -I${CMAKE_SOURCE_DIR}/gpgme-vala/src) +set(CFLAGS ${VALA_CFLAGS} ${LIBDINO_CFLAGS}) add_definitions(${CFLAGS}) add_library(libdino SHARED ${LIBDINO_VALA_C} ${LIBDINO_GRESOURCES_TARGET}) add_dependencies(libdino xmpp-vala-vapi qlite-vapi gpgme-vapi) @@ -155,5 +155,5 @@ set_target_properties(libdino PROPERTIES PREFIX "") add_custom_target(dino-vapi DEPENDS - ${CMAKE_BINARY_DIR}/libdino/dino.vapi + ${CMAKE_BINARY_DIR}/exports/dino.vapi ) diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index cfb14eed..ce00206e 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -17,18 +17,18 @@ vala_precompile(MAIN_VALA_C SOURCES src/main.vala CUSTOM_VAPIS - ${CMAKE_BINARY_DIR}/xmpp-vala/xmpp-vala.vapi - ${CMAKE_BINARY_DIR}/qlite/qlite.vapi - ${CMAKE_BINARY_DIR}/libdino/dino.vapi + ${CMAKE_BINARY_DIR}/exports/xmpp-vala.vapi + ${CMAKE_BINARY_DIR}/exports/qlite.vapi + ${CMAKE_BINARY_DIR}/exports/dino_internal.vapi PACKAGES ${MAIN_PACKAGES} OPTIONS --target-glib=2.38 - -g + ${GLOBAL_DEBUG_FLAGS} --thread ) -set(CFLAGS ${VALA_CFLAGS} ${MAIN_CFLAGS} -I${CMAKE_BINARY_DIR}/xmpp-vala -I${CMAKE_BINARY_DIR}/qlite -I${CMAKE_BINARY_DIR}/libdino) +set(CFLAGS ${VALA_CFLAGS} ${MAIN_CFLAGS}) add_definitions(${CFLAGS}) add_executable(dino ${MAIN_VALA_C}) add_dependencies(dino dino-vapi) diff --git a/qlite/CMakeLists.txt b/qlite/CMakeLists.txt index 70ac249f..2aeabb79 100644 --- a/qlite/CMakeLists.txt +++ b/qlite/CMakeLists.txt @@ -29,9 +29,8 @@ GENERATE_VAPI GENERATE_HEADER qlite OPTIONS - -g + ${GLOBAL_DEBUG_FLAGS} --thread - --vapidir=${CMAKE_SOURCE_DIR}/vapi ) set(CFLAGS ${VALA_CFLAGS} ${QLITE_CFLAGS}) @@ -41,6 +40,6 @@ target_link_libraries(qlite ${QLITE_LIBRARIES}) add_custom_target(qlite-vapi DEPENDS - ${CMAKE_BINARY_DIR}/qlite/qlite.vapi + ${CMAKE_BINARY_DIR}/exports/qlite.vapi ) diff --git a/xmpp-vala/CMakeLists.txt b/xmpp-vala/CMakeLists.txt index 77e16136..00a86e88 100644 --- a/xmpp-vala/CMakeLists.txt +++ b/xmpp-vala/CMakeLists.txt @@ -66,7 +66,7 @@ SOURCES "src/module/xep/pixbuf_storage.vala" CUSTOM_VAPIS "${CMAKE_CURRENT_SOURCE_DIR}/vapi/uuid.vapi" - "${CMAKE_BINARY_DIR}/gpgme-vala/gpgme.vapi" + "${CMAKE_BINARY_DIR}/exports/gpgme.vapi" PACKAGES ${ENGINE_PACKAGES} GENERATE_VAPI @@ -75,12 +75,11 @@ GENERATE_HEADER xmpp-vala OPTIONS --target-glib=2.38 - -g + ${GLOBAL_DEBUG_FLAGS} --thread - --vapidir=${CMAKE_SOURCE_DIR}/vapi ) -set(CFLAGS ${VALA_CFLAGS} ${ENGINE_CFLAGS} ${GPGME_CFLAGS} ${LIBUUID_CFLAGS} -I${CMAKE_BINARY_DIR}/gpgme-vala -I${CMAKE_SOURCE_DIR}/gpgme-vala/src) +set(CFLAGS ${VALA_CFLAGS} ${ENGINE_CFLAGS} ${GPGME_CFLAGS} ${LIBUUID_CFLAGS}) add_definitions(${CFLAGS}) add_library(xmpp-vala SHARED ${ENGINE_VALA_C}) add_dependencies(xmpp-vala gpgme-vapi) @@ -88,6 +87,6 @@ target_link_libraries(xmpp-vala gpgme-vala ${ENGINE_LIBRARIES} ${GPGME_LIBRARIES add_custom_target(xmpp-vala-vapi DEPENDS - ${CMAKE_BINARY_DIR}/xmpp-vala/xmpp-vala.vapi + ${CMAKE_BINARY_DIR}/exports/xmpp-vala.vapi )