source: icGREP/icgrep-devel/icgrep/combine/pugixml/CMakeLists.txt @ 5516

Last change on this file since 5516 was 5516, checked in by faldebey, 22 months ago

added combinatorial testing tool

File size: 2.6 KB
RevLine 
[5516]1project(pugixml)
2
3cmake_minimum_required(VERSION 2.6)
4
5option(BUILD_SHARED_LIBS "Build shared instead of static library" OFF)
6option(BUILD_TESTS "Build tests" OFF)
7option(BUILD_PKGCONFIG "Build in PKGCONFIG mode" OFF)
8
9set(BUILD_DEFINES "" CACHE STRING "Build defines")
10
11if(MSVC)
12        option(STATIC_CRT "Use static CRT libraries" OFF)
13
14        # Rewrite command line flags to use /MT if necessary
15        if(STATIC_CRT)
16                foreach(flag_var
17                                CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
18                                CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
19                        if(${flag_var} MATCHES "/MD")
20                                string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
21                        endif(${flag_var} MATCHES "/MD")
22                endforeach(flag_var)
23        endif()
24endif()
25
26# Pre-defines standard install locations on *nix systems.
27include(GNUInstallDirs)
28mark_as_advanced(CLEAR CMAKE_INSTALL_LIBDIR CMAKE_INSTALL_INCLUDEDIR)
29
30set(HEADERS src/pugixml.hpp src/pugiconfig.hpp)
31set(SOURCES ${HEADERS} src/pugixml.cpp)
32
33if(DEFINED BUILD_DEFINES)
34        foreach(DEFINE ${BUILD_DEFINES})
35                add_definitions("-D" ${DEFINE})
36        endforeach()
37endif()
38
39if(BUILD_SHARED_LIBS)
40        add_library(pugixml SHARED ${SOURCES})
41else()
42        add_library(pugixml STATIC ${SOURCES})
43endif()
44
45# Enable C++11 long long for compilers that are capable of it
46if(NOT ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} STRLESS 3.1 AND ";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";cxx_long_long_type;")
47        target_compile_features(pugixml PUBLIC cxx_long_long_type)
48endif()
49
50set_target_properties(pugixml PROPERTIES VERSION 1.8 SOVERSION 1)
51get_target_property(PUGIXML_VERSION_STRING pugixml VERSION)
52
53if(BUILD_PKGCONFIG)
54        # Install library into its own directory under LIBDIR
55        set(INSTALL_SUFFIX /pugixml-${PUGIXML_VERSION_STRING})
56endif()
57
58install(TARGETS pugixml EXPORT pugixml-config
59        ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}${INSTALL_SUFFIX}
60        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${INSTALL_SUFFIX}
61        RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
62install(FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}${INSTALL_SUFFIX})
63install(EXPORT pugixml-config DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pugixml)
64
65if(BUILD_PKGCONFIG)
66        configure_file(scripts/pugixml.pc.in ${PROJECT_BINARY_DIR}/pugixml.pc @ONLY)
67        install(FILES ${PROJECT_BINARY_DIR}/pugixml.pc DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig)
68endif()
69
70if(BUILD_TESTS)
71        file(GLOB TEST_SOURCES tests/*.cpp)
72        file(GLOB FUZZ_SOURCES tests/fuzz_*.cpp)
73        list(REMOVE_ITEM TEST_SOURCES ${FUZZ_SOURCES})
74
75        add_executable(check ${TEST_SOURCES})
76        target_link_libraries(check pugixml)
77        add_custom_command(TARGET check POST_BUILD COMMAND check WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
78endif()
Note: See TracBrowser for help on using the repository browser.