11#
2- # Copyright 2021-2023 Ribose Inc. (https://www.ribose.com)
2+ # Copyright 2021-2024 Ribose Inc. (https://www.ribose.com)
33#
44# Permission is hereby granted, free of charge, to any person obtaining a copy of
55# this software and associated documentation files (the "Software"), to deal in
@@ -35,33 +35,21 @@ option(WITH_SEXP_TESTS "Build tests" ON)
3535option (WITH_SEXP_CLI "Build sexp console application" ON )
3636option (WITH_SANITIZERS "Enable ASAN and other sanitizers" OFF )
3737option (WITH_COVERAGE "Enable coverage report" OFF )
38+ option (WITH_ABI_TEST "Configure for ABI compatibility test" OFF )
3839option (DOWNLOAD_GTEST "Download googletest" ON )
3940option (BUILD_SHARED_LIBS "Build shared library" OFF )
4041
4142include (GNUInstallDirs )
4243include (CheckCXXSourceCompiles )
4344
44- if (BUILD_SHARED_LIBS )
45- set (TYPE "SHARED" )
46- else (BUILD_SHARED_LIBS )
47- set (TYPE "STATIC" )
48- endif (BUILD_SHARED_LIBS )
49-
50- if (BUILD_SHARED_LIBS AND MSVC )
51- message (FATAL_ERROR "Building sexp shared library with MSVC is not supported" )
52- endif (BUILD_SHARED_LIBS AND MSVC )
53-
54-
55- message (STATUS "Building ${TYPE} library" )
56-
5745if (WITH_SANITIZERS)
5846 if (NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
5947 message (FATAL_ERROR "Sanitizers work with clang compiler only." )
6048 endif ()
6149 if (NOT CMAKE_BUILD_TYPE MATCHES "Debug" )
6250 message (STATUS "Forcing build type to Debug for sanitizers" )
6351 set (CMAKE_BUILD_TYPE Debug CACHE STRING "Build type. Forced to Debug" FORCE )
64- set (WITH_TESTS ON CACHE STRING "Forced to ON" FORCE )
52+ set (WITH_SEXP_TESTS ON CACHE STRING "Forced to ON" FORCE )
6553 endif ()
6654endif ()
6755
@@ -72,10 +60,45 @@ if (WITH_COVERAGE)
7260 if (NOT CMAKE_BUILD_TYPE MATCHES "Debug" )
7361 message (STATUS "Forcing build type to Debug for coverage" )
7462 set (CMAKE_BUILD_TYPE Debug CACHE STRING "Build type. Forced to Debug" FORCE )
63+ set (WITH_SEXP_TESTS ON CACHE STRING "Forced to ON" FORCE )
64+ endif ()
65+ endif ()
66+
67+ if (WITH_ABI_TEST)
68+ if (NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU" )
69+ message (FATAL_ERROR "Abi test works with GNU compiler only." )
70+ endif ()
71+ if (NOT CMAKE_BUILD_TYPE MATCHES "Debug" )
72+ message (STATUS "Forcing build type to Debug for abi test" )
73+ set (CMAKE_BUILD_TYPE Debug CACHE STRING "Build type. Forced to Debug" FORCE )
7574 set (WITH_TESTS ON CACHE STRING "Forced to ON" FORCE )
7675 endif ()
76+ if (WITH_SEXP_TESTS)
77+ message (STATUS "Disabling tests build for abi test" )
78+ set (WITH_SEXP_TESTS OFF CACHE STRING "Forced to OFF" FORCE )
79+ endif ()
80+ if (WITH_SEXP_CLI)
81+ message (STATUS "Disabling sexp cli application build for abi test" )
82+ set (WITH_SEXP_CLI OFF CACHE STRING "Forced to OFF" FORCE )
83+ endif ()
84+ if (NOT BUILD_SHARED_LIBS )
85+ message (STATUS "Forcing shared libs for abi test" )
86+ set (BUILD_SHARED_LIBS ON CACHE STRING "Forced to ON" FORCE )
87+ endif ()
7788endif ()
7889
90+ if (BUILD_SHARED_LIBS )
91+ set (TYPE "SHARED" )
92+ else (BUILD_SHARED_LIBS )
93+ set (TYPE "STATIC" )
94+ endif (BUILD_SHARED_LIBS )
95+
96+ if (BUILD_SHARED_LIBS AND MSVC )
97+ message (FATAL_ERROR "Building sexp shared library with MSVC is not supported" )
98+ endif (BUILD_SHARED_LIBS AND MSVC )
99+
100+ message (STATUS "Building ${TYPE} library" )
101+
79102if (NOT CMAKE_BUILD_TYPE )
80103 message (STATUS "Defaulting build type to Debug" )
81104 set (CMAKE_BUILD_TYPE Debug)
@@ -93,6 +116,10 @@ if (WITH_COVERAGE)
93116 link_libraries (--coverage )
94117endif (WITH_COVERAGE )
95118
119+ if (WITH_ABI_TEST)
120+ add_compile_options (-Og )
121+ endif (WITH_ABI_TEST )
122+
96123# set warning flags at the top level
97124if (NOT MSVC )
98125 add_compile_options (
0 commit comments