Skip to content

Commit

Permalink
add install script
Browse files Browse the repository at this point in the history
  • Loading branch information
daonvshu committed May 7, 2024
1 parent 1cca39a commit 6411c72
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.2)
cmake_minimum_required(VERSION 3.12)

project(qrouter)

Expand Down
46 changes: 40 additions & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
cmake_minimum_required(VERSION 3.2)
project(qrouterlib)
cmake_minimum_required(VERSION 3.12)

project(qrouter VERSION 0.0.8)

set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

find_package(QT NAMES Qt6 Qt5 REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Widgets REQUIRED)

set(CMAKE_DEBUG_POSTFIX "d")

add_library(${PROJECT_NAME}
abstractrouterwidget.cpp
qrouter.cpp
Expand All @@ -16,12 +19,43 @@ add_library(${PROJECT_NAME}
container/stackroutercontainer.cpp
)

target_include_directories(${PROJECT_NAME} PUBLIC ../include)

add_library(qrouter::lib ALIAS ${PROJECT_NAME})

target_link_libraries(${PROJECT_NAME}
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Widgets
)

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

include(CMakePackageConfigHelpers)

install(TARGETS ${PROJECT_NAME}
EXPORT QRouterTargets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)

install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../include/
DESTINATION include
FILES_MATCHING PATTERN "*.h"
)

configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/QRouterConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/QRouterConfig.cmake"
INSTALL_DESTINATION lib/cmake/QRouter
)

install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/QRouterConfig.cmake"
DESTINATION lib/cmake/QRouter
)

install(EXPORT QRouterTargets
FILE QRouterTargets.cmake
DESTINATION lib/cmake/QRouter
)
6 changes: 6 additions & 0 deletions src/QRouterConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@PACKAGE_INIT@

include(CMakeFindDependencyMacro)
@_find_dependency_calls@

include("${CMAKE_CURRENT_LIST_DIR}/QRouterTargets.cmake")
4 changes: 2 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.2)
cmake_minimum_required(VERSION 3.12)
project(qroutertest)

set(CMAKE_CXX_STANDARD 14)
Expand Down Expand Up @@ -30,5 +30,5 @@ target_link_libraries(${PROJECT_NAME}
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Widgets
qrouter::lib
qrouter
)

0 comments on commit 6411c72

Please sign in to comment.