From 54d90a937cf85571c2b018e21c3d0be01fe6d7a2 Mon Sep 17 00:00:00 2001 From: xiaoji <345865759@163.com> Date: Mon, 18 Mar 2024 16:23:01 +0800 Subject: [PATCH] fixed cmake building soversion is diffrent with automake --- CMakeLists.txt | 10 +++++++++- README.rst | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a93a711..b821aba7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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( " diff --git a/README.rst b/README.rst index 4a307dc1..1c3a7661 100644 --- a/README.rst +++ b/README.rst @@ -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 -------------