1*2e9d4914SAndroid Build Coastguard Workercmake_minimum_required(VERSION 3.1) 2*2e9d4914SAndroid Build Coastguard Worker 3*2e9d4914SAndroid Build Coastguard Worker# Extract version from configure.ac. 4*2e9d4914SAndroid Build Coastguard Workerset(VERSION_REGEX "^AC_INIT\\(libconfig,[ \t]+([0-9.]+),.*") 5*2e9d4914SAndroid Build Coastguard Workerfile(STRINGS "configure.ac" 6*2e9d4914SAndroid Build Coastguard Worker VERSION_STRING REGEX ${VERSION_REGEX}) 7*2e9d4914SAndroid Build Coastguard Workerstring(REGEX REPLACE ${VERSION_REGEX} "\\1" VERSION_STRING "${VERSION_STRING}") 8*2e9d4914SAndroid Build Coastguard Worker 9*2e9d4914SAndroid Build Coastguard Workerproject(libconfig LANGUAGES C CXX VERSION ${VERSION_STRING}) 10*2e9d4914SAndroid Build Coastguard Workeroption(BUILD_EXAMPLES "Enable examples" ON) 11*2e9d4914SAndroid Build Coastguard Workeroption(BUILD_SHARED_LIBS "Enable shared library" ON) 12*2e9d4914SAndroid Build Coastguard Workeroption(BUILD_TESTS "Enable tests" ON) 13*2e9d4914SAndroid Build Coastguard Worker 14*2e9d4914SAndroid Build Coastguard Workerset_property(GLOBAL PROPERTY USE_FOLDERS ON) 15*2e9d4914SAndroid Build Coastguard Worker 16*2e9d4914SAndroid Build Coastguard Workerset(CMAKE_C_STANDARD 99) 17*2e9d4914SAndroid Build Coastguard Workerset(CMAKE_C_EXTENSIONS ON) 18*2e9d4914SAndroid Build Coastguard Worker 19*2e9d4914SAndroid Build Coastguard Workerset(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out) 20*2e9d4914SAndroid Build Coastguard Workerset(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out) 21*2e9d4914SAndroid Build Coastguard Workerset(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out) 22*2e9d4914SAndroid Build Coastguard Worker 23*2e9d4914SAndroid Build Coastguard Workerinclude(GNUInstallDirs) 24*2e9d4914SAndroid Build Coastguard Workerinclude(CheckSymbolExists) 25*2e9d4914SAndroid Build Coastguard Workeradd_subdirectory(lib) 26*2e9d4914SAndroid Build Coastguard Worker 27*2e9d4914SAndroid Build Coastguard Workerif(BUILD_EXAMPLES) 28*2e9d4914SAndroid Build Coastguard Worker add_subdirectory(examples) 29*2e9d4914SAndroid Build Coastguard Workerendif() 30*2e9d4914SAndroid Build Coastguard Worker 31*2e9d4914SAndroid Build Coastguard Workerif(BUILD_TESTS) 32*2e9d4914SAndroid Build Coastguard Worker enable_testing() 33*2e9d4914SAndroid Build Coastguard Worker add_subdirectory(tinytest) 34*2e9d4914SAndroid Build Coastguard Worker add_subdirectory(tests) 35*2e9d4914SAndroid Build Coastguard Workerendif() 36