vendredi 28 décembre 2018

CMake source_group doesn't work on Qtcreator

In my project I have a top level CMakeLists.txt where I define general project properties:

cmake_minimum_required(VERSION 3.11 FATAL_ERROR)

find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
    set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
endif (CCACHE_PROGRAM)

set_property(GLOBAL PROPERTY USE_FOLDERS ON)

project(databaseclient LANGUAGES CXX VERSION 0.1.0.0 DESCRIPTION "Asynchronous database client")

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

if (NOT CMAKE_BUILD_TYPE)
   set(CMAKE_BUILD_TYPE DEBUG)
endif(NOT CMAKE_BUILD_TYPE)

add_subdirectory(src)

And in my project's source folder I define an OBJECT library that will later be linked to static and dynamic libraries:

set(
  SOURCE_FILES
    ${PROJECT_SOURCE_DIR}/include/databaseclient/parameters.hpp
)
add_library(
  ${PROJECT_NAME}
    OBJECT
      ${SOURCE_FILES}
)
set_target_properties(
  ${PROJECT_NAME}
    PROPERTIES
      VERSION ${PROJECT_VERSION}
      POSITION_INDEPENDENT_CODE ON
)
target_compile_features(
  ${PROJECT_NAME}
    PUBLIC
      cxx_std_11 cxx_noexcept
      cxx_auto_type
      cxx_constexpr
      cxx_deleted_functions
      cxx_inline_namespaces
      cxx_lambdas
      cxx_noexcept
      cxx_nullptr
      cxx_override
      cxx_range_for
)
target_compile_definitions(
  ${PROJECT_NAME}
    PRIVATE
      ASIO_STANDALONE=1
      ASIO_NO_EXCEPTIONS=1
      ASIO_NO_DEPRECATED=1
)
target_include_directories(
  ${PROJECT_NAME}
    PRIVATE
      ${byte-lite_SOURCE_DIR}/include/nonstd
      ${asio_SOURCE_DIR}/asio/include/
      ${PROJECT_SOURCE_DIR}/include/
)

QtCreator creates a folder structure where a node has the full path to my source files, which is obviously suboptimal. I tried to add a source_group to the list under the src folder but QtCreator seems to just ignore it.

How can I get source_group to work?

Aucun commentaire:

Enregistrer un commentaire