Skip to content
Snippets Groups Projects
Commit 04022505 authored by Christian Dreher's avatar Christian Dreher
Browse files

refactor: Partial implementation of new CMake API.

parent 00c0a22d
No related branches found
No related tags found
1 merge request!66Refactor/new arch
......@@ -33,7 +33,75 @@ function(armarx_add_qt_library TARGET)
message(FATAL_ERROR "${TARGET}: Unknown arguments `${AX_UNPARSED_ARGUMENTS}`.")
endif()
# TODO: Migrate from armarx_gui_plugin.
# Variables that are modified within this context.
set(SOURCES ${AX_SOURCES})
set(HEADERS ${AX_HEADERS} ${AX_UI_FILES})
set(DEPENDENCIES ${AX_DEPENDENCIES})
armarx_find_qt_base("QtCore;QtGui;QtOpenGL;QtXml;QtScript;QtDesigner" REQUIRED)
if(NOT "${TARGET}" STREQUAL "ArmarXGuiBase")
if(DEPENDENCIES)
list(APPEND DEPENDENCIES ArmarXCore ArmarXGuiBase ${QT_LIBRARIES})
else()
set(DEPENDENCIES ArmarXCore ArmarXGuiBase ${QT_LIBRARIES})
endif()
endif()
set(GENERATE_BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_autogen/include")
install(DIRECTORY "${GENERATE_BASE_DIR}" DESTINATION "include" COMPONENT headers)
printtarget("${HEADERS}" "${SOURCES}" "${AX_RESOURCE_FILES}" "${DEPENDENCIES}")
armarx_add_library("${TARGET}"
SOURCES "${SOURCES}"
HEADERS "${HEADERS}"
DEPENDENCIES "${DEPENDENCIES}"
)
target_include_directories("${TARGET}" PUBLIC $<BUILD_INTERFACE:${GENERATE_BASE_DIR}> )
target_compile_definitions("${TARGET}" PUBLIC -DQ_COMPILER_INITIALIZER_LISTS)
set_target_properties("${TARGET}" PROPERTIES AUTOMOC ON)
set_target_properties("${TARGET}" PROPERTIES AUTOUIC ON)
set_target_properties("${TARGET}" PROPERTIES AUTORCC ON)
set_target_properties("${TARGET}" PROPERTIES AUTOUIC_SEARCH_PATHS ${${ARMARX_PROJECT_NAME}_SOURCE_DIR}/source)
file(RELATIVE_PATH CORRECT_INCLUDE "${CMAKE_SOURCE_DIR}/source" ${CMAKE_CURRENT_SOURCE_DIR})
message(STATUS "cmake: ${CMAKE_COMMAND} ${TARGET}")
add_custom_command(
TARGET ${TARGET}
POST_BUILD COMMAND ${CMAKE_COMMAND}
ARGS "-DPROJECT_NAME=${PROJECT_NAME}"
"-DDIR=${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_autogen/include/"
"-DCORRECT_INCLUDE=${CORRECT_INCLUDE}"
"-DPROJECT_SOURCE_DIR=${CMAKE_SOURCE_DIR}/source"
"-P" "${ArmarXGui_CMAKE_DIR}/check_qt_moc_includes.cmake"
COMMENT "Checking Qt MOC includes."
)
endfunction()
function(armarx_add_qt_plugin TARGET)
# Parse arguments.
set(single_param)
set(flag_param)
set(multi_param PLUGIN_SOURCES PLUGIN_HEADERS SOURCES HEADERS UI_FILES RESOURCE_FILES
DEPENDENCIES)
cmake_parse_arguments(PARSE_ARGV 1 AX "${flag_param}" "${single_param}" "${multi_param}")
if(DEFINED AX_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "${TARGET}: Unknown arguments `${AX_UNPARSED_ARGUMENTS}`.")
endif()
armarx_add_qt_library("${PLUGIN_NAME}"
SOURCES "${SOURCES}"
QT_MOC_HDRS "${HEADERS}"
QT_UIS ""
QT_RESOURCES "${AX_QT_RESOURCES}"
DEPENDENCIES "${AX_DEPENDENCIES}"
)
endfunction()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment