diff options
| -rw-r--r-- | KF5ConfigMacros.cmake | 27 | ||||
| -rw-r--r-- | autotests/kconfig_compiler/CMakeLists.txt | 41 | ||||
| -rw-r--r-- | autotests/kconfig_compiler/test1.kcfgc | 1 | ||||
| -rw-r--r-- | autotests/kconfig_compiler/test12.kcfgc | 1 | ||||
| -rw-r--r-- | autotests/kconfig_compiler/test13.kcfgc | 1 | ||||
| -rw-r--r-- | autotests/kconfig_compiler/test9.kcfgc | 1 | ||||
| -rw-r--r-- | autotests/kconfig_compiler/test_qdebugcategory.kcfgc | 2 | 
7 files changed, 35 insertions, 39 deletions
| diff --git a/KF5ConfigMacros.cmake b/KF5ConfigMacros.cmake index 5faccb2f..e92f4a31 100644 --- a/KF5ConfigMacros.cmake +++ b/KF5ConfigMacros.cmake @@ -32,7 +32,7 @@  # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF  # SUCH DAMAGE. -macro (KCONFIG_ADD_KCFG_FILES _sources ) +function (KCONFIG_ADD_KCFG_FILES _sources )     foreach (_current_ARG ${ARGN})        if( ${_current_ARG} STREQUAL "GENERATE_MOC" )           set(_kcfg_generatemoc TRUE) @@ -43,6 +43,8 @@ macro (KCONFIG_ADD_KCFG_FILES _sources )        endif()     endforeach () +   set(sources) +     foreach (_current_FILE ${ARGN})       if(NOT ${_current_FILE} STREQUAL "GENERATE_MOC" AND NOT ${_current_FILE} STREQUAL "USE_RELATIVE_PATH") @@ -61,12 +63,16 @@ macro (KCONFIG_ADD_KCFG_FILES _sources )         get_filename_component(_basename ${_tmp_FILE} NAME_WE)         # If we had a relative path and we're asked to use it, then change the basename accordingly -       if(NOT ${_rel_PATH} STREQUAL "") +       if(_rel_PATH)             set(_basename ${_rel_PATH}/${_basename})         endif()         file(READ ${_tmp_FILE} _contents) -       string(REGEX REPLACE "^(.*\n)?File=([^\n]+kcfg).*\n.*$" "\\2"  _kcfg_FILENAME "${_contents}") +       string(REGEX MATCH "File=([^\n]+\\.kcfg)\n" "" "${_contents}") +       set(_kcfg_FILENAME "${CMAKE_MATCH_1}") +       if (NOT _kcfg_FILENAME) +            message(WARNING "Couldn't read the \"File\" field in ${_tmp_FILE}") +       endif()         set(_src_FILE    ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)         set(_header_FILE ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)         set(_moc_FILE    ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc) @@ -77,7 +83,7 @@ macro (KCONFIG_ADD_KCFG_FILES _sources )         endif()         if(NOT EXISTS "${_kcfg_FILE}") -           message(ERROR "${_kcfg_FILENAME} not found; tried in ${_abs_PATH} and ${CMAKE_CURRENT_BINARY_DIR}") +           message(FATAL_ERROR "${_kcfg_FILENAME} not found; tried in ${_abs_PATH} and ${CMAKE_CURRENT_BINARY_DIR}")         endif()         # make sure the directory exist in the build directory @@ -93,13 +99,16 @@ macro (KCONFIG_ADD_KCFG_FILES _sources )                            DEPENDS ${_kcfg_FILE})         if(_kcfg_generatemoc) -          qt5_generate_moc(${_header_FILE} ${_moc_FILE} ) -          set_source_files_properties(${_src_FILE} PROPERTIES SKIP_AUTOMOC TRUE)  # don't run automoc on this file -          list(APPEND ${_sources} ${_moc_FILE}) +          list(APPEND sources ${_moc_FILE}) +          qt5_generate_moc(${_header_FILE} ${_moc_FILE}) +          set_property(SOURCE ${_src_FILE} PROPERTY SKIP_AUTOMOC TRUE)  # don't run automoc on this file +          set_property(SOURCE ${_src_FILE} APPEND PROPERTY OBJECT_DEPENDS ${_moc_FILE} )         endif() -       list(APPEND ${_sources} ${_src_FILE} ${_header_FILE}) +       list(APPEND sources ${_src_FILE} ${_header_FILE})       endif(NOT ${_current_FILE} STREQUAL "GENERATE_MOC" AND NOT ${_current_FILE} STREQUAL "USE_RELATIVE_PATH")     endforeach (_current_FILE) -endmacro (KCONFIG_ADD_KCFG_FILES) +   set(${_sources} ${${_sources}} ${sources} PARENT_SCOPE) + +endfunction(KCONFIG_ADD_KCFG_FILES) diff --git a/autotests/kconfig_compiler/CMakeLists.txt b/autotests/kconfig_compiler/CMakeLists.txt index 1ea6472a..0971471b 100644 --- a/autotests/kconfig_compiler/CMakeLists.txt +++ b/autotests/kconfig_compiler/CMakeLists.txt @@ -10,26 +10,10 @@ endif()  # make sure the generated headers can be found  include_directories(${KCFG_OUTPUT_DIR}) +include(${CMAKE_SOURCE_DIR}/KF5ConfigMacros.cmake)  macro(GEN_KCFG_TEST_SOURCE _testName _srcs) -   cmake_parse_arguments(ARG "" "KCFG" "" ${ARGN} ) -   set(_kcfgFile ${ARG_KCFG}) -   if (NOT _kcfgFile) -      set(_kcfgFile "${_testName}.kcfg") -   endif() -   add_custom_command( -      OUTPUT ${KCFG_OUTPUT_DIR}/${_testName}.cpp ${KCFG_OUTPUT_DIR}/${_testName}.h -      COMMAND KF5::kconfig_compiler ${CMAKE_CURRENT_SOURCE_DIR}/${_kcfgFile} ${CMAKE_CURRENT_SOURCE_DIR}/${_testName}.kcfgc -      WORKING_DIRECTORY ${KCFG_OUTPUT_DIR} -      DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_kcfgFile} ${CMAKE_CURRENT_SOURCE_DIR}/${_testName}.kcfgc KF5::kconfig_compiler) - -   # set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${_testName}.h PROPERTIES GENERATED TRUE) -   qt5_generate_moc(${KCFG_OUTPUT_DIR}/${_testName}.h ${KCFG_OUTPUT_DIR}/${_testName}.moc ) -   # do not run automoc on the generated file -   set_source_files_properties(${KCFG_OUTPUT_DIR}/${_testName}.cpp PROPERTIES SKIP_AUTOMOC TRUE) - -   set( ${_srcs} ${${_srcs}} ${KCFG_OUTPUT_DIR}/${_testName}.cpp) -   set_property(SOURCE ${KCFG_OUTPUT_DIR}/${_testName}.cpp APPEND PROPERTY OBJECT_DEPENDS ${KCFG_OUTPUT_DIR}/${_testName}.moc ) -endmacro(GEN_KCFG_TEST_SOURCE) +   KCONFIG_ADD_KCFG_FILES(${_srcs} ${_testName}.kcfgc ${ARGN}) +endmacro()  include(ECMMarkAsTest) @@ -181,7 +165,7 @@ target_link_libraries(test12 KF5::ConfigGui)  set(test13_SRCS test13main.cpp ) -gen_kcfg_test_source(test13 test13_SRCS) +gen_kcfg_test_source(test13 test13_SRCS GENERATE_MOC)  ecm_add_test(TEST_NAME test13 ${test13_SRCS})  target_link_libraries(test13 KF5::ConfigGui) @@ -200,17 +184,17 @@ target_link_libraries(test_dpointer KF5::ConfigGui)  ########### next target ###############  set(test_signal_SRCS test_signal_main.cpp ) -gen_kcfg_test_source(test_signal test_signal_SRCS) +gen_kcfg_test_source(test_signal test_signal_SRCS GENERATE_MOC)  ecm_add_test(TEST_NAME test_signal ${test_signal_SRCS})  target_link_libraries(test_signal KF5::ConfigGui)  ########### next target ###############  set(kconfigcompiler_test_signals_SRCS kconfigcompiler_test_signals.cpp) -gen_kcfg_test_source(signals_test_singleton kconfigcompiler_test_signals_SRCS KCFG signals_test.kcfg) -gen_kcfg_test_source(signals_test_no_singleton kconfigcompiler_test_signals_SRCS KCFG signals_test.kcfg) -gen_kcfg_test_source(signals_test_singleton_dpointer kconfigcompiler_test_signals_SRCS KCFG signals_test.kcfg) -gen_kcfg_test_source(signals_test_no_singleton_dpointer kconfigcompiler_test_signals_SRCS KCFG signals_test.kcfg) +gen_kcfg_test_source(signals_test_singleton kconfigcompiler_test_signals_SRCS GENERATE_MOC) +gen_kcfg_test_source(signals_test_no_singleton kconfigcompiler_test_signals_SRCS GENERATE_MOC) +gen_kcfg_test_source(signals_test_singleton_dpointer kconfigcompiler_test_signals_SRCS GENERATE_MOC) +gen_kcfg_test_source(signals_test_no_singleton_dpointer kconfigcompiler_test_signals_SRCS GENERATE_MOC)  ecm_add_test(${kconfigcompiler_test_signals_SRCS}      TEST_NAME kconfigcompiler-signals-test @@ -236,7 +220,7 @@ target_link_libraries(test_qdebugcategory KF5::ConfigGui)  ########### next target ###############  set(test_translation_qt_SRCS test_translation_qt_main.cpp) -gen_kcfg_test_source(test_translation_qt test_translation_qt_SRCS KCFG test_translation.kcfg) +gen_kcfg_test_source(test_translation_qt test_translation_qt_SRCS)  ecm_add_test(TEST_NAME test_translation_qt ${test_translation_qt_SRCS})  target_link_libraries(test_translation_qt KF5::ConfigGui) @@ -244,7 +228,7 @@ target_link_libraries(test_translation_qt KF5::ConfigGui)  ########### next target ###############  set(test_translation_kde_SRCS test_translation_kde_main.cpp) -gen_kcfg_test_source(test_translation_kde test_translation_kde_SRCS KCFG test_translation.kcfg) +gen_kcfg_test_source(test_translation_kde test_translation_kde_SRCS)  ecm_add_test(TEST_NAME test_translation_kde ${test_translation_kde_SRCS})  target_link_libraries(test_translation_kde KF5::ConfigGui) @@ -252,8 +236,7 @@ target_link_libraries(test_translation_kde KF5::ConfigGui)  ########### next target ###############  set(test_translation_kde_domain_SRCS test_translation_kde_domain_main.cpp) -gen_kcfg_test_source(test_translation_kde_domain test_translation_kde_domain_SRCS KCFG test_translation.kcfg) +gen_kcfg_test_source(test_translation_kde_domain test_translation_kde_domain_SRCS)  ecm_add_test(TEST_NAME test_translation_kde_domain ${test_translation_kde_domain_SRCS})  target_link_libraries(test_translation_kde_domain KF5::ConfigGui) - diff --git a/autotests/kconfig_compiler/test1.kcfgc b/autotests/kconfig_compiler/test1.kcfgc index 2c8c096b..a96bcfc1 100644 --- a/autotests/kconfig_compiler/test1.kcfgc +++ b/autotests/kconfig_compiler/test1.kcfgc @@ -1,5 +1,6 @@  # Code generation options for kconfig_compiler_kf5  ClassName=Test1 +File=test1.kcfg  #  # Singleton=false  # diff --git a/autotests/kconfig_compiler/test12.kcfgc b/autotests/kconfig_compiler/test12.kcfgc index 1ed82e7e..d3a8fe2f 100644 --- a/autotests/kconfig_compiler/test12.kcfgc +++ b/autotests/kconfig_compiler/test12.kcfgc @@ -1 +1,2 @@  ClassName=Test12 +File=test12.kcfg diff --git a/autotests/kconfig_compiler/test13.kcfgc b/autotests/kconfig_compiler/test13.kcfgc index 340b8cae..a0c3c13e 100644 --- a/autotests/kconfig_compiler/test13.kcfgc +++ b/autotests/kconfig_compiler/test13.kcfgc @@ -1,3 +1,4 @@  ClassName=Test13  GenerateProperties=true  Mutators=brightness +File=test13.kcfg diff --git a/autotests/kconfig_compiler/test9.kcfgc b/autotests/kconfig_compiler/test9.kcfgc index cf416bb9..429de9c0 100644 --- a/autotests/kconfig_compiler/test9.kcfgc +++ b/autotests/kconfig_compiler/test9.kcfgc @@ -1,5 +1,6 @@  # Code generation options for kconfig_compiler_kf5  ClassName=Test9 +File=test9.kcfg  #  # Singleton=false  # diff --git a/autotests/kconfig_compiler/test_qdebugcategory.kcfgc b/autotests/kconfig_compiler/test_qdebugcategory.kcfgc index a7ae26e7..032d032e 100644 --- a/autotests/kconfig_compiler/test_qdebugcategory.kcfgc +++ b/autotests/kconfig_compiler/test_qdebugcategory.kcfgc @@ -1,5 +1,5 @@  # Code generation options for kconfig_compiler_kf5 -File=test_qdebugcategory.kcfgc +File=test_qdebugcategory.kcfg  ClassName=TestQCategory  Singleton=false  Mutators=true | 
