diff --git a/src/Tools/plugins/widget/CMakeLists.txt b/src/Tools/plugins/widget/CMakeLists.txt index b7d1695eb0..cdcdceb2f6 100644 --- a/src/Tools/plugins/widget/CMakeLists.txt +++ b/src/Tools/plugins/widget/CMakeLists.txt @@ -1,11 +1,17 @@ -project(FreeCAD_widgets) -cmake_minimum_required(VERSION 3.2.0) +if (PROJECT_NAME) + set(IS_SUB_PROJECT TRUE) +endif() -#set(CMAKE_INCLUDE_CURRENT_DIR ON) -#set(CMAKE_AUTOMOC ON) +if (NOT IS_SUB_PROJECT) + project(FreeCAD_widgets) + cmake_minimum_required(VERSION 3.2.0) -#find_package(Qt5Widgets REQUIRED) -#find_package(Qt5Designer REQUIRED) + set(CMAKE_INCLUDE_CURRENT_DIR ON) + set(CMAKE_AUTOMOC ON) + + find_package(Qt5Widgets REQUIRED) + find_package(Qt5Designer REQUIRED) +endif() include_directories( ${Qt5Core_INCLUDE_DIRS} @@ -48,17 +54,19 @@ endif() target_link_libraries(FreeCAD_widgets PRIVATE ${Qt5Widgets_LIBRARIES} ${Qt5Designer_LIBRARIES}) target_compile_options(FreeCAD_widgets PRIVATE ${COMPILE_OPTIONS}) -set (libFreeCAD_widgets "libFreeCAD_widgets" PARENT_SCOPE) # Get the install location of a plugin to determine the path to designer plguins get_target_property(QMAKE_EXECUTABLE Qt5::qmake LOCATION) exec_program(${QMAKE_EXECUTABLE} ARGS "-query QT_INSTALL_PLUGINS" RETURN_VALUE return_code OUTPUT_VARIABLE DEFAULT_QT_PLUGINS_DIR ) set(DESIGNER_PLUGIN_LOCATION ${DEFAULT_QT_PLUGINS_DIR}/designer CACHE FILEPATH "Path where the plugin will be installed to") -#message(STATUS "Plugin will be installed to: ${DESIGNER_PLUGIN_LOCATION}") -# Override the CMake variable -#set(CMAKE_INSTALL_PREFIX ${DESIGNER_PLUGIN_LOCATION} CACHE PATH "Install path to Qt Designer plugins" FORCE) +if (NOT IS_SUB_PROJECT) + message(STATUS "Plugin will be installed to: ${DESIGNER_PLUGIN_LOCATION}") +else() + set (libFreeCAD_widgets "${CMAKE_SHARED_LIBRARY_PREFIX}FreeCAD_widgets${CMAKE_SHARED_LIBRARY_SUFFIX}" PARENT_SCOPE) +endif() + INSTALL(TARGETS FreeCAD_widgets LIBRARY DESTINATION "$ENV{DESTDIR}${DESIGNER_PLUGIN_LOCATION}"