Ticket #72: CMakeLists.txt

File CMakeLists.txt, 1.2 KB (added by clive.crous@…, 6 years ago)

CMakeLists.txt for building libyaml with cmake

Line 
1PROJECT(libyaml C)
2
3SET(YAML_VERSION_MAJOR 0)
4SET(YAML_VERSION_MINOR 0)
5SET(YAML_VERSION_PATCH 1)
6
7SET(YAML_VERSION_STRING "${YAML_VERSION_MAJOR}.${YAML_VERSION_MINOR}.${YAML_VERSION_PATCH}")
8
9INCLUDE_DIRECTORIES(include)
10
11ADD_DEFINITIONS(-DYAML_VERSION_MAJOR=${YAML_VERSION_MAJOR})
12ADD_DEFINITIONS(-DYAML_VERSION_MINOR=${YAML_VERSION_MINOR})
13ADD_DEFINITIONS(-DYAML_VERSION_PATCH=${YAML_VERSION_PATCH})
14ADD_DEFINITIONS(-DYAML_VERSION_STRING=\\"${YAML_VERSION_STRING}\\")
15
16FILE(GLOB SRC src/*.c include/*.h)
17ADD_LIBRARY(yaml ${SRC})
18
19IF(MINGW)
20  GET_FILENAME_COMPONENT(MINGW_BIN "${CMAKE_C_COMPILER}" PATH)
21  GET_FILENAME_COMPONENT(MINGW_ROOT "${MINGW_BIN}" PATH CACHE)
22  SET(LIBYAML_INSTALL_PREFIX "${MINGW_ROOT}" CACHE PATH "MinGW default install path")
23ELSE(MINGW)
24  SET(LIBYAML_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE PATH "default install path")
25ENDIF(MINGW)
26SET(CMAKE_INSTALL_PREFIX ${LIBYAML_INSTALL_PREFIX} CACHE INTERNAL "")
27
28OPTION(BUILD_SHARED_LIBS "Library Build type" true)
29IF(NOT BUILD_SHARED_LIBS)
30    ADD_DEFINITIONS(-DYAML_DECLARE_STATIC)
31ENDIF(NOT BUILD_SHARED_LIBS)
32
33INSTALL(TARGETS yaml DESTINATION lib)
34INSTALL(FILES "include/yaml.h" DESTINATION include)