The real CMake support

This patch provides a CMakeLists.txt file to build JSON-C library without relying on auto-tools support. This makes the build a bit more portable and cleaner.

It can detect headers and symbols and generate config.h header file based on those detections. It cannot yet handle ctest(1) as the testing itself depends on comparing the output against files. Testing would need some creative abuse of CMake :) This will be provided a few patches later and may possibly involve refactoring test cases.

The patch has been tested on GCC 4.8.5 (Linux), GCC 7.2.0 (MinGW) and Microsoft Visual C++ 16.0 (2010?) locally. Also, compiles correctly on Travis CI and AppVeyor without errors.
This commit is contained in:
Unmanned Player
2018-07-24 08:06:13 +10:00
parent 2327b23d8e
commit f2e991a341
6 changed files with 487 additions and 155 deletions

View File

@@ -1,39 +1,37 @@
version: '{branch}.{build}'
os: Windows Server 2012 R2
configuration:
- Debug
- Release
platform: x64
# There should be a better way to set-up a build matrix.
environment:
matrix:
- PlatformToolset: v140
- PlatformToolset: v120
- PlatformToolset: Windows7.1SDK
- b_toolset: Windows7.1SDK
b_config: Debug
- b_toolset: Windows7.1SDK
b_config: Release
- b_toolset: v120
b_config: Debug
- b_toolset: v120
b_config: Release
- b_toolset: v140
b_config: Debug
- b_toolset: v140
b_config: Release
build_script:
- cmake .
- >
msbuild "json-c.vcxproj" /m /verbosity:normal
/logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
/p:PlatformToolset=%PlatformToolset% /p:OutDir=lib\
- cmake -T %b_toolset% -DCMAKE_BUILD_TYPE=%b_config% -DCMAKE_INSTALL_PREFIX=t_install .
- cmake --build . --target install
after_build:
- md include\json-c
- copy json.h include\json-c\*
- copy debug.h include\json-c\*
- copy linkhash.h include\json-c\*
- copy arraylist.h include\json-c\*
- copy json_util.h include\json-c\*
- copy json_object.h include\json-c\*
- copy json_tokener.h include\json-c\*
- copy json_object_iterator.h include\json-c\*
- copy json_c_version.h include\json-c\*
- copy json_inttypes.h include\json-c\*
- copy include\json_config.h include\json-c\*
- copy json_object_private.h include\json-c\*
- 7z a json-c.lib.zip lib\json-c.dll %Configuration%\json-c.lib %Configuration%\json-c.exp %Configuration%\json-c.pdb include\json-c\*.h
- cd t_install
- 7z a ../json-c.win32.%b_toolset%.%b_config%.zip *
artifacts:
- path: json-c.lib.zip
name: json-c.lib.zip
- path: json-c.win32.%b_toolset%.%b_config%.zip
name: json-c.win32.%b_toolset%.%b_config%.zip