Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CMake #13

Merged
merged 5 commits into from
Jul 12, 2024
Merged

Update CMake #13

merged 5 commits into from
Jul 12, 2024

Conversation

henricj
Copy link
Contributor

@henricj henricj commented Dec 30, 2022

Enhance the CMake build to support:

  • Building both static and shared libraries (code changes would be needed on Windows to produce a usable DLL).
  • CPack
  • Building documentation (when possible).
  • Configuration checks are done to more closely match the autoconf build.

Two GitHub workflows are supplied to test the CMake-based build. One does a normal build and the other runs a CodeQL analysis. Both workflows run for Windows, Linux, and macOS.

@henricj henricj marked this pull request as ready for review December 30, 2022 21:00
@mywave82

This comment was marked as outdated.

@mywave82

This comment was marked as outdated.

@mywave82
Copy link
Contributor

Updating configure.ac so that version.text.in works for both, and also suggest that we use ChangeLog instead of doc/version.texi as the source of the date?

--- a/configure.ac
+++ b/configure.ac
@@ -1,12 +1,18 @@
 AC_INIT(binio,1.5,[dn.tlp@gmx.net],libbinio)
 AC_CONFIG_SRCDIR(src/binio.cpp)
-AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile src/binio.h libbinio.pc])
+AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile src/binio.h libbinio.pc doc/version.texi])
 AM_INIT_AUTOMAKE
 AM_MAINTAINER_MODE
 #AM_DISABLE_SHARED
 AM_PROG_LIBTOOL
 AC_LANG(C++)
 
+AC_SUBST(at, "@")
+AC_SUBST(libbinio_VERSION, [$VERSION])
+timestamp=`stat --format=%Y ChangeLog`
+AC_SUBST(LIBBINIO_TEXI_UPDATED, [`date -u --date=@$timestamp +"%d %B %Y"`])
+AC_SUBST(LIBBINIO_TEXI_MONTH_UPDATED, [`date -u --date=@$timestamp +"%B %Y"`])
+
 # Check for a sane C/C++ build environment.
 AC_PROG_MAKE_SET
 AC_PROG_INSTALL

@mywave82
Copy link
Contributor

Second minor issue, following https://alexreinking.com/blog/building-a-dual-shared-and-static-library-with-cmake.html , the dual shared/static install fails, they both overwrite the same file cmake config file during install with oposite static and shared information

cmake --install build-shared --prefix _install
...
cmake --install build-static --prefix _install
...
-- Old export file "_install/lib/cmake/libbinio/libbinio-static-targets.cmake" will be replaced.  Removing files [/home/stian/adplug/libbinio-2-build/_install/lib/cmake/libbinio/libbinio-static-targets-release.cmake].
...

@mywave82
Copy link
Contributor

mywave82 commented Jan 7, 2024

Second minor issue, following https://alexreinking.com/blog/building-a-dual-shared-and-static-library-with-cmake.html , the dual shared/static install fails, they both overwrite the same file cmake config file during install with oposite static and shared information

cmake --install build-shared --prefix _install
...
cmake --install build-static --prefix _install
...
-- Old export file "_install/lib/cmake/libbinio/libbinio-static-targets.cmake" will be replaced.  Removing files [/home/stian/adplug/libbinio-2-build/_install/lib/cmake/libbinio/libbinio-static-targets-release.cmake].
...

This is fixed with the commit I added on your branch

@mywave82
Copy link
Contributor

mywave82 commented Jan 7, 2024

CI however fails with

Error: vcpkg failed with: Could not locate a manifest (vcpkg.json) above the current working directory.
This vcpkg distribution does not have a classic mode instance.



    at Object.<anonymous> (D:\a\_actions\lukka\run-cmake\v10\dist\index.js:6984:23)
    at Generator.next (<anonymous>)
    at fulfilled (D:\a\_actions\lukka\run-cmake\v10\dist\index.js:6942:58)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Error: run-cmake action execution failed: 'Error: vcpkg failed with: Could not locate a manifest (vcpkg.json) above the current working directory.
This vcpkg distribution does not have a classic mode instance.

henricj added 2 commits July 9, 2024 23:04
Specify the C++ language version.
Don't let MSVC get misled by user code pages.
Get the CMake build to behave more like the automake build.
@mywave82 mywave82 force-pushed the cmake_build branch 4 times, most recently from acb1a9f to 42269a0 Compare July 9, 2024 21:29
henricj and others added 3 commits July 12, 2024 12:11
-- Installing: /home/stian/SORT/adplug/libbinio-cmake/_install/lib/cmake/libbinio/libbinio-static-targets.cmake
-- Installing: /home/stian/SORT/adplug/libbinio-cmake/_install/lib/cmake/libbinio/libbinio-static-targets-release.cmake

instead of

-- Installing: /home/stian/SORT/adplug/libbinio-cmake/_install/lib/cmake/libbinio/libbinio-shared-targets.cmake
-- Installing: /home/stian/SORT/adplug/libbinio-cmake/_install/lib/cmake/libbinio/libbinio-shared-targets-release.cmake

if invoked like this:
$ cmake -G Ninja -S . -B build-shared -DBUILD_SHARED_LIBS=YES -DCMAKE_BUILD_TYPE=Release
$ cmake --build build-shared
$ cmake --install build-shared --prefix _install
@mywave82 mywave82 merged commit 9be48f6 into adplug:master Jul 12, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants