Skip to content

Commit

Permalink
chore: add CMakeLists.
Browse files Browse the repository at this point in the history
  • Loading branch information
HuaiminNotSleepYet committed Sep 13, 2024
1 parent bd34884 commit 2543f86
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 0 deletions.
50 changes: 50 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
cmake_minimum_required(VERSION 3.12)

project(nwidget VERSION 0.1.0 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)

add_library(nwidget INTERFACE)

target_include_directories(nwidget
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

include(GNUInstallDirs)

install(TARGETS nwidget
EXPORT nwidget-targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

include(CMakePackageConfigHelpers)

write_basic_package_version_file(
${PROJECT_BINARY_DIR}/nwidget-config-version.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
configure_package_config_file(
${PROJECT_SOURCE_DIR}/cmake/nwidget-config.cmake.in
${PROJECT_BINARY_DIR}/nwidget-config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nwidget/cmake
)

install(EXPORT nwidget-targets
FILE nwidget-targets.cmake
NAMESPACE nwidget::
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nwidget/cmake
)

install(FILES
${PROJECT_BINARY_DIR}/nwidget-config.cmake
${PROJECT_BINARY_DIR}/nwidget-config-version.cmake
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nwidget/cmake
)

install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/nwidget DESTINATION include)
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,20 @@ nw::asprintf("%d", slider1.value() + slider2.value())
- Easy to maintain
- Fun
## Installing
```shell
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX:PATH=/installation/path
cmake --build . --config Release --target install
```

```cmake
find_package(nwidget CONFIG REQUIRED)
target_link_libraries(main PRIVATE nwidget::nwidget)
```

## Examples

[NWidget Gallery](./examples/gallery) : [Widget Gallery](https://doc.qt.io/qt-6/qtwidgets-gallery-example.html) written with nwidget.
Expand Down
3 changes: 3 additions & 0 deletions cmake/nwidget-config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/nwidget-targets.cmake")
14 changes: 14 additions & 0 deletions doc/zh_cn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,20 @@ nw::asprintf("%d", slider1.value() + slider2.value())
- 易于维护
- 有趣
## 安装
```shell
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX:PATH=/installation/path
cmake --build . --config Release --target install
```

```cmake
find_package(nwidget CONFIG REQUIRED)
target_link_libraries(main PRIVATE nwidget::nwidget)
```

## 示例

[NWidget Gallery](../../examples/gallery):用 nwidget 编写的 [Widget Gallery](https://doc.qt.io/qt-6/qtwidgets-gallery-example.html)
Expand Down

0 comments on commit 2543f86

Please sign in to comment.