fixed cmake building soversion is diffrent with automake

This commit is contained in:
xiaoji 2024-03-18 16:23:01 +08:00
parent 842708ac0c
commit 54d90a937c
2 changed files with 27 additions and 1 deletions

View File

@ -314,11 +314,19 @@ if(JANSSON_BUILD_SHARED_LIBS)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--default-symver")
else()
# some linkers may only support --version-script
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/jansson.sym" "JANSSON_${JANSSON_SOVERSION} {
if (UNIX)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/jansson.sym" "libjansson.so.${JANSSON_SOVERSION} {
global:
*;
};
")
else ()
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/jansson.sym" "JANSSON_${JANSSON_SOVERSION} {
global:
*;
};
")
endif ()
list(APPEND CMAKE_REQUIRED_LIBRARIES "-Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/jansson.sym")
check_c_source_compiles(
"

View File

@ -29,6 +29,10 @@ source distribution for details.
Compilation and Installation
----------------------------
Unix-like building system
It supports Unix-like Operating System and MingW.
If you obtained a ``jansson-X.Y.tar.*`` tarball from GitHub Releases, just use
the standard autotools commands::
@ -45,6 +49,20 @@ script has to be generated first. The easiest way is to use autoreconf::
$ autoreconf -i
Cmake building system
It supports Windows, MacOS, Linux, Android and many other OS.
$ mkdir build && cd build
$ cmake ..
$ make
To run the test suite, invoke::
$ ctest
If you want to building the shared libraries, please add
-DJANSSON_BUILD_SHARED_LIBS=ON
Documentation
-------------