Skip to content

Commit

Permalink
Merge branch 'fix/lib_linking'
Browse files Browse the repository at this point in the history
  • Loading branch information
jacquetc committed Mar 5, 2024
2 parents d5a399d + cc86088 commit 2a4c223
Show file tree
Hide file tree
Showing 16 changed files with 224 additions and 262 deletions.
128 changes: 64 additions & 64 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
cmake_minimum_required(VERSION 3.21)


list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)

# get version from git

include(VersionFromGit)
version_from_git(
LOG ON
)
version_from_git(LOG ON)
add_compile_definitions(QLEANY_VERSION_SEMANTIC="${SEMVER}")
set(QLEANY_VERSION_SEMANTIC ${SEMVER})
add_compile_definitions(QLEANY_VERSION="${VERSION}")
Expand All @@ -20,9 +16,11 @@ set(QLEANY_VERSION_MINOR ${VERSION_MINOR})
add_compile_definitions(QLEANY_VERSION_PATCH=${VERSION_PATCH})
set(QLEANY_VERSION_PATCH ${VERSION_PATCH})



project(Qleany VERSION ${QLEANY_VERSION} LANGUAGES CXX DESCRIPTION "Qleany is a light framework for Clean Architecture with Qt6")
project(
Qleany
VERSION ${QLEANY_VERSION}
LANGUAGES CXX
DESCRIPTION "Qleany is a light framework for Clean Architecture with Qt6")
string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER)

# Compiler settings
Expand Down Expand Up @@ -51,15 +49,24 @@ else()
endif()

# Add Qt components
find_package(Qt6 COMPONENTS Core Sql Concurrent REQUIRED)
find_package(
Qt6
COMPONENTS Core Sql Concurrent
REQUIRED)
qt_standard_project_setup()

if(QLEANY_BUILD_WITH_QT_GUI)
find_package(Qt6 COMPONENTS Gui REQUIRED)
find_package(
Qt6
COMPONENTS Gui
REQUIRED)
endif()

if(QLEANY_BUILD_EXAMPLES)
find_package(Qt6 COMPONENTS Widgets REQUIRED)
find_package(
Qt6
COMPONENTS Widgets
REQUIRED)
endif()

find_package(QCoro6 REQUIRED COMPONENTS Core)
Expand All @@ -69,103 +76,96 @@ qcoro_enable_coroutines()

# configure the library
file(GLOB_RECURSE SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
file(GLOB_RECURSE PUBLIC_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/include/${PROJECT_NAME_LOWER}/*.h")
file(GLOB_RECURSE PUBLIC_HEADERS
"${CMAKE_CURRENT_SOURCE_DIR}/include/qleany/*.h")

message(STATUS "PUBLIC_HEADERS: ${PUBLIC_HEADERS}")

# Create the library target
add_library(Qleany ${LIB_TYPE}
${SOURCES}
${PUBLIC_HEADERS}
)
add_library(qleany ${LIB_TYPE} ${SOURCES} ${PUBLIC_HEADERS})

# Generate export header
message(STATUS "Generating export header")

include(GenerateExportHeader)
generate_export_header(Qleany
EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/include/qleany/qleany_export.h
)
generate_export_header(
qleany EXPORT_FILE_NAME
${CMAKE_CURRENT_BINARY_DIR}/include/qleany/qleany_export.h)

target_include_directories(${PROJECT_NAME} PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/include
)
target_include_directories(qleany PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/include)

target_include_directories(${PROJECT_NAME} PUBLIC
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/qleany>
target_include_directories(
qleany
PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/qleany>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)

set_target_properties(Qleany PROPERTIES CXX_STANDARD 20)
set_target_properties(qleany PROPERTIES CXX_STANDARD 20)

set_target_properties(Qleany PROPERTIES OUTPUT_NAME ${PROJECT_NAME_LOWER})
set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER "${PUBLIC_HEADERS};${CMAKE_CURRENT_BINARY_DIR}/include/qleany/qleany_export.h")
set_target_properties(${PROJECT_NAME} PROPERTIES
POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS}
)
set_target_properties(qleany PROPERTIES OUTPUT_NAME qleany)
set_target_properties(
qleany
PROPERTIES
PUBLIC_HEADER
"${PUBLIC_HEADERS};${CMAKE_CURRENT_BINARY_DIR}/include/qleany/qleany_export.h"
)
set_target_properties(qleany PROPERTIES POSITION_INDEPENDENT_CODE
${BUILD_SHARED_LIBS})

target_link_libraries(Qleany PUBLIC Qt6::Core Qt6::Concurrent Qt6::Sql)
target_link_libraries(qleany PUBLIC Qt6::Core Qt6::Concurrent Qt6::Sql)

if(QLEANY_BUILD_WITH_QT_GUI)
target_link_libraries(Qleany PRIVATE Qt::Gui)
target_link_libraries(qleany PRIVATE Qt::Gui)
endif()

# state that Qleany need PIC when the default is shared libraries
set_target_properties(Qleany PROPERTIES
POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS}
)

set_target_properties(qleany PROPERTIES POSITION_INDEPENDENT_CODE
${BUILD_SHARED_LIBS})

# configure the install location
message(STATUS "Configuring install location")
include(GNUInstallDirs)

# Install library
install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}Targets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
PUBLIC_HEADER DESTINATION include/qleany
)
install(
TARGETS qleany
EXPORT qleanyTargets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
PUBLIC_HEADER DESTINATION include/qleany)

# Install public headers
install(DIRECTORY include/${PROJECT_NAME_LOWER} DESTINATION include)

install(DIRECTORY include/qleany DESTINATION include)

# install license
install(FILES LICENSE DESTINATION share/${PROJECT_NAME_LOWER})

install(FILES LICENSE DESTINATION share/qleany)

# Install the export set for use with the install-tree
install(EXPORT ${PROJECT_NAME}Targets
FILE ${PROJECT_NAME_LOWER}Targets.cmake
DESTINATION lib/cmake/${PROJECT_NAME_LOWER}
)
install(
EXPORT qleanyTargets
FILE qleanyTargets.cmake
DESTINATION lib/cmake/qleany)

# Create and install qleanyConfig.cmake
message(STATUS "Creating and installing qleanyConfig.cmake")
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
${PROJECT_NAME_LOWER}ConfigVersion.cmake
qleanyConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)

configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME_LOWER}Config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME_LOWER}Config.cmake
INSTALL_DESTINATION lib/cmake/${PROJECT_NAME_LOWER})
${CMAKE_CURRENT_SOURCE_DIR}/qleanyConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/qleanyConfig.cmake
INSTALL_DESTINATION lib/cmake/qleany)

install(FILES
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME_LOWER}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME_LOWER}ConfigVersion.cmake
DESTINATION lib/cmake/${PROJECT_NAME_LOWER})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qleanyConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/qleanyConfigVersion.cmake
DESTINATION lib/cmake/qleany)

# Export the targets to a script
# message(STATUS "Exporting targets to a script")
# export(EXPORT ${PROJECT_NAME}Targets
# FILE ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME_LOWER}Targets.cmake)

# message(STATUS "Exporting targets to a script") export(EXPORT
# ${PROJECT_NAME}Targets FILE ${CMAKE_CURRENT_BINARY_DIR}/qleanyTargets.cmake)

# Subdirectories that contain CMakeLists.txt for the framework tests and example
if(QLEANY_BUILD_TESTS)
Expand Down
2 changes: 1 addition & 1 deletion examples/front_ends/src/core/contracts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ target_link_libraries(${LIBRARY_NAME} PRIVATE front-ends-example-entities)
target_link_libraries(${LIBRARY_NAME}
PRIVATE Qt6::Core Qt6::Sql
)
target_link_libraries(${LIBRARY_NAME} PRIVATE Qleany)
target_link_libraries(${LIBRARY_NAME} PRIVATE qleany)
2 changes: 1 addition & 1 deletion examples/front_ends/src/core/entities/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ target_include_directories(${LIBRARY_NAME} PUBLIC
)

target_link_libraries(${LIBRARY_NAME} PRIVATE Qt6::Core )
target_link_libraries(${LIBRARY_NAME} PRIVATE Qleany)
target_link_libraries(${LIBRARY_NAME} PRIVATE qleany)
4 changes: 2 additions & 2 deletions examples/front_ends/src/core/interactor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ target_link_libraries(${LIBRARY_NAME} PUBLIC front-ends-example-application-feat
target_link_libraries(${LIBRARY_NAME} PRIVATE
Qt6::Core Qt6::Gui)
target_link_libraries(${LIBRARY_NAME} PRIVATE QCoro::Core)
target_link_libraries(${LIBRARY_NAME} PRIVATE Qleany)
target_link_libraries(${LIBRARY_NAME} PRIVATE qleany)

if(IOS)
install(TARGETS ${LIBRARY_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
Expand All @@ -63,4 +63,4 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
install(TARGETS ${LIBRARY_NAME}
RUNTIME DESTINATION ${BINDIR}
LIBRARY DESTINATION ${LIBDIR})
endif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
endif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
2 changes: 1 addition & 1 deletion examples/front_ends/src/core/persistence/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ target_link_libraries(${LIBRARY_NAME} PRIVATE front-ends-example-entities)
target_link_libraries(${LIBRARY_NAME}
PRIVATE Qt6::Core Qt6::Sql
)
target_link_libraries(${LIBRARY_NAME} PRIVATE Qleany)
target_link_libraries(${LIBRARY_NAME} PRIVATE qleany)

if(IOS)
install(TARGETS ${LIBRARY_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
Expand Down
2 changes: 1 addition & 1 deletion examples/front_ends/src/gui/presenter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ target_include_directories(${LIBRARY_NAME} PUBLIC
target_link_libraries(${LIBRARY_NAME} PRIVATE
Qt6::Core Qt6::Gui)
target_link_libraries(${LIBRARY_NAME} PRIVATE QCoro::Core)
target_link_libraries(${LIBRARY_NAME} PUBLIC Qleany)
target_link_libraries(${LIBRARY_NAME} PUBLIC qleany)
target_link_libraries(${LIBRARY_NAME} PUBLIC front-ends-example-interactor)

if(IOS)
Expand Down
25 changes: 14 additions & 11 deletions examples/front_ends/src/gui/qt_widgets_application/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,30 @@ project(FrontEndsExampleDesktopApp LANGUAGES CXX)

set(APP_NAME front-ends-example-desktop-application)

find_package(Qt6 COMPONENTS Core Gui Widgets Concurrent Sql REQUIRED)
find_package(
Qt6
COMPONENTS Core Gui Widgets Concurrent Sql
REQUIRED)

find_package(QCoro6 REQUIRED COMPONENTS Core)
# find_package(qleany REQUIRED)
# Set necessary compiler flags to enable coroutine support
# find_package(qleany REQUIRED) Set necessary compiler flags to enable coroutine
# support
qcoro_enable_coroutines()

if (Qt6_VERSION VERSION_GREATER_EQUAL 6.3)
qt_standard_project_setup()
if(Qt6_VERSION VERSION_GREATER_EQUAL 6.3)
qt_standard_project_setup()
endif()

# Create an executable target for the example project
add_executable(${APP_NAME}
main.cpp
mainwindow.h mainwindow.cpp mainwindow.ui
# add other source files
add_executable(
${APP_NAME} main.cpp mainwindow.h mainwindow.cpp mainwindow.ui # add other
# source files
)

target_link_libraries(${APP_NAME} PUBLIC Qt6::Core Qt6::Widgets Qt6::Concurrent Qt6::Sql)
target_link_libraries(${APP_NAME} PUBLIC Qt6::Core Qt6::Widgets Qt6::Concurrent
Qt6::Sql)
# Link the example against the Qleany library
target_link_libraries(${APP_NAME} PUBLIC Qleany)
target_link_libraries(${APP_NAME} PUBLIC qleany)
target_link_libraries(${APP_NAME} PUBLIC front-ends-example-entities)
target_link_libraries(${APP_NAME} PUBLIC front-ends-example-persistence)
target_link_libraries(${APP_NAME} PUBLIC front-ends-example-interactor)
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/src/core/contracts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ target_link_libraries(${LIBRARY_NAME} PRIVATE simple-example-entities)
target_link_libraries(${LIBRARY_NAME}
PRIVATE Qt6::Core Qt6::Sql
)
target_link_libraries(${LIBRARY_NAME} PRIVATE Qleany)
target_link_libraries(${LIBRARY_NAME} PRIVATE qleany)
2 changes: 1 addition & 1 deletion examples/simple/src/core/entities/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ target_include_directories(${LIBRARY_NAME} PUBLIC
)

target_link_libraries(${LIBRARY_NAME} PRIVATE Qt6::Core )
target_link_libraries(${LIBRARY_NAME} PRIVATE Qleany)
target_link_libraries(${LIBRARY_NAME} PRIVATE qleany)
2 changes: 1 addition & 1 deletion examples/simple/src/core/interactor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ target_link_libraries(${LIBRARY_NAME} PUBLIC simple-example-application-feature-
target_link_libraries(${LIBRARY_NAME} PRIVATE
Qt6::Core Qt6::Gui)
target_link_libraries(${LIBRARY_NAME} PRIVATE QCoro::Core)
target_link_libraries(${LIBRARY_NAME} PRIVATE Qleany)
target_link_libraries(${LIBRARY_NAME} PRIVATE qleany)

if(IOS)
install(TARGETS ${LIBRARY_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/src/core/persistence/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ target_link_libraries(${LIBRARY_NAME} PRIVATE simple-example-entities)
target_link_libraries(${LIBRARY_NAME}
PRIVATE Qt6::Core Qt6::Sql
)
target_link_libraries(${LIBRARY_NAME} PRIVATE Qleany)
target_link_libraries(${LIBRARY_NAME} PRIVATE qleany)

if(IOS)
install(TARGETS ${LIBRARY_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
Expand Down
26 changes: 14 additions & 12 deletions examples/simple/src/gui/desktop_application/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,30 @@ project(SimpleExampleDesktopApp LANGUAGES CXX)

set(APP_NAME simple-example-desktop-application)

find_package(Qt6 COMPONENTS Core Gui Widgets Concurrent Sql REQUIRED)
find_package(
Qt6
COMPONENTS Core Gui Widgets Concurrent Sql
REQUIRED)

find_package(QCoro6 REQUIRED COMPONENTS Core)
# find_package(qleany REQUIRED)
# Set necessary compiler flags to enable coroutine support
# find_package(qleany REQUIRED) Set necessary compiler flags to enable coroutine
# support
qcoro_enable_coroutines()

if (Qt6_VERSION VERSION_GREATER_EQUAL 6.3)
qt_standard_project_setup()
if(Qt6_VERSION VERSION_GREATER_EQUAL 6.3)
qt_standard_project_setup()
endif()

# Create an executable target for the example project
add_executable(${APP_NAME}
main.cpp
mainwindow.h mainwindow.cpp mainwindow.ui
# add other source files for the example
add_executable(
${APP_NAME} main.cpp mainwindow.h mainwindow.cpp mainwindow.ui
# add other source files for the example
)
add_dependencies(${APP_NAME} Qleany)

target_link_libraries(${APP_NAME} PUBLIC Qt6::Core Qt6::Widgets Qt6::Concurrent Qt6::Sql)
target_link_libraries(${APP_NAME} PUBLIC Qt6::Core Qt6::Widgets Qt6::Concurrent
Qt6::Sql)
# Link the example against the Qleany library
target_link_libraries(${APP_NAME} PUBLIC Qleany)
target_link_libraries(${APP_NAME} PUBLIC qleany)
target_link_libraries(${APP_NAME} PUBLIC simple-example-entities)
target_link_libraries(${APP_NAME} PUBLIC simple-example-persistence)
target_link_libraries(${APP_NAME} PUBLIC simple-example-interactor)
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/src/gui/presenter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ target_include_directories(${LIBRARY_NAME} PUBLIC
target_link_libraries(${LIBRARY_NAME} PRIVATE
Qt6::Core Qt6::Gui)
target_link_libraries(${LIBRARY_NAME} PRIVATE QCoro::Core)
target_link_libraries(${LIBRARY_NAME} PUBLIC Qleany)
target_link_libraries(${LIBRARY_NAME} PUBLIC qleany)
target_link_libraries(${LIBRARY_NAME} PUBLIC simple-example-interactor)

if(IOS)
Expand Down
Loading

0 comments on commit 2a4c223

Please sign in to comment.