-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from abelcheung/cmake-migration
build: Retire autotools and switch to cmake, closes #21
- Loading branch information
Showing
17 changed files
with
1,195 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: CMake compatibility check | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
check: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
cmake_ver: | ||
- 3.27.7 | ||
- 3.26.5 | ||
- 3.25.3 | ||
- 3.24.4 | ||
- 3.23.5 | ||
- 3.22.6 | ||
- 3.21.7 | ||
- 3.20.6 | ||
- 3.19.8 | ||
- 3.18.6 | ||
- 3.17.5 | ||
- 3.16.9 | ||
- 3.15.7 | ||
- 3.14.7 | ||
- 3.13.5 | ||
- 3.12.4 | ||
- 3.11.4 | ||
- 3.10.3 | ||
- 3.9.6 | ||
- 3.8.2 | ||
- 3.7.2 | ||
- 3.6.3 | ||
- 3.5.2 | ||
- 3.4.3 | ||
- 3.3.2 | ||
- 3.2.3 | ||
- 3.1.3 | ||
- 3.0.2 | ||
runs-on: macos-12 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: lukka/get-cmake@latest | ||
with: | ||
cmakeVersion: ${{ matrix.cmake_ver }} | ||
ninjaVersion: latest | ||
|
||
- name: Check cmake invocation | ||
run: | | ||
mkdir build | ||
cmake -S . -B build -G Ninja | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,12 @@ | ||
**/*.exe | ||
**/*.o | ||
**/.deps | ||
**/Makefile | ||
**/Makefile.in | ||
/.dirstamp | ||
|
||
# IDE or editor files | ||
/.vscode | ||
/ABOUT-NLS | ||
/aclocal.m4 | ||
/autom4te.cache | ||
/compile | ||
/config.cache | ||
/config.guess | ||
/config.h | ||
/config.h.in | ||
/config.log | ||
/config.rpath | ||
/config.status | ||
/config.sub | ||
/configure | ||
/depcomp | ||
/install-sh | ||
/m4 | ||
/missing | ||
/mkinstalldirs | ||
/po/*.gmo | ||
/po/*.header | ||
/po/*.mo | ||
/po/*.pot | ||
/po/*.sed | ||
/po/insert-header.sin | ||
/po/Makefile.in.in | ||
/po/Makevars.template | ||
/po/POTFILES | ||
/po/remove-potcdate.sin | ||
/po/Rules-quot | ||
/po/stamp-it | ||
/po/stamp-po | ||
/src/rifiuti | ||
/src/rifiuti-vista | ||
/stamp-h1 | ||
/test/atconfig | ||
/test/atlocal | ||
/test/package.m4 | ||
/test/testsuite | ||
/test/testsuite.dir | ||
/test/testsuite.log | ||
/test/test_glib_iconv | ||
/.idea | ||
**/*.bak | ||
**/*~ | ||
|
||
# CMake | ||
/build* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
cmake_minimum_required(VERSION 3.17 FATAL_ERROR) # cmake -E rm | ||
|
||
project(rifiuti2 | ||
VERSION 0.7.0 | ||
HOMEPAGE_URL https://github.com/abelcheung/rifiuti2/ | ||
LANGUAGES C) | ||
|
||
if(NOT WIN32) | ||
include(GNUInstallDirs) | ||
endif() | ||
|
||
set(CMAKE_C_STANDARD 11) | ||
set(CMAKE_C_STANDARD_REQUIRED ON) | ||
|
||
set(CMAKE_C_FLAGS_DEBUG "-O0 -ggdb -Wall") | ||
set(CMAKE_STATIC_LINKER_FLAGS "-static") | ||
configure_file(config.h.in config.h) | ||
|
||
find_package(PkgConfig REQUIRED) | ||
pkg_check_modules(GLIB REQUIRED "glib-2.0 >= 2.40.0") | ||
|
||
# Do static build in Windows, which require finding | ||
# extra libraries | ||
if (WIN32) | ||
pkg_check_modules(ICONV REQUIRED "iconv") | ||
list(APPEND GLIB_STATIC_CFLAGS_OTHER -DGLIB_STATIC_COMPILATION) | ||
endif() | ||
|
||
foreach(bin rifiuti rifiuti-vista) | ||
add_executable( | ||
${bin} | ||
src/${bin}.c | ||
src/${bin}.h | ||
) | ||
target_include_directories( | ||
${bin} BEFORE | ||
PRIVATE | ||
${CMAKE_CURRENT_BINARY_DIR} | ||
) | ||
target_sources( | ||
${bin} | ||
PRIVATE | ||
src/utils.c | ||
src/utils.h | ||
) | ||
if(WIN32) | ||
target_sources(${bin} PRIVATE src/utils-win.c src/utils-win.h) | ||
target_include_directories(${bin} PRIVATE | ||
${GLIB_STATIC_INCLUDE_DIRS} ${ICONV_STATIC_INCLUDE_DIRS}) | ||
target_compile_options (${bin} PRIVATE | ||
${GLIB_STATIC_CFLAGS_OTHER} ${ICONV_STATIC_CFLAGS_OTHER}) | ||
target_link_libraries (${bin} PRIVATE authz | ||
${GLIB_STATIC_LIBRARIES} ${ICONV_STATIC_LIBRARIES}) | ||
target_link_directories (${bin} PRIVATE | ||
${GLIB_STATIC_LIBRARY_DIRS} ${ICONV_STATIC_LIBRARY_DIRS}) | ||
target_link_options (${bin} BEFORE PRIVATE ${CMAKE_STATIC_LINKER_FLAGS}) | ||
else() | ||
target_include_directories(${bin} PRIVATE ${GLIB_INCLUDE_DIRS}) | ||
target_compile_options (${bin} PRIVATE ${GLIB_CFLAGS_OTHER}) | ||
target_link_libraries (${bin} PRIVATE ${GLIB_LIBRARIES}) | ||
target_link_directories (${bin} PRIVATE ${GLIB_LIBRARY_DIRS}) | ||
endif() | ||
endforeach() | ||
|
||
install( | ||
TARGETS | ||
rifiuti | ||
rifiuti-vista | ||
RUNTIME | ||
) | ||
if(NOT WIN32) | ||
install( | ||
FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/rifiuti.1 | ||
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 | ||
) | ||
endif() | ||
install( | ||
FILES | ||
${CMAKE_CURRENT_SOURCE_DIR}/LICENSE | ||
${CMAKE_CURRENT_SOURCE_DIR}/NEWS.md | ||
${CMAKE_CURRENT_SOURCE_DIR}/README.md | ||
${CMAKE_CURRENT_SOURCE_DIR}/docs/THANKS.txt | ||
TYPE DOC | ||
) | ||
|
||
include(CTest) | ||
add_subdirectory(test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#cmakedefine PROJECT_NAME "@PROJECT_NAME@" | ||
#cmakedefine PROJECT_VERSION "@PROJECT_VERSION@" | ||
#cmakedefine PROJECT_HOMEPAGE_URL "@PROJECT_HOMEPAGE_URL@" | ||
|
||
#define G_LOG_DOMAIN PROJECT_NAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.