Debian Codegraph @

src/vendor/azure-uamqp-c/deps/azure-c-shared-utility/testtools/ctest/CMakeLists.txt

raw
1 #Copyright (c) Microsoft. All rights reserved.
2 #Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
4 cmake_minimum_required(VERSION 2.8.11)
5
6 if(TARGET ctest)
7 RETURN()
8 endif()
9
10 project(ctest)
11
12 set(CTEST_VERSION 1.1.19)
13
14 #Use solution folders.
15 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
16
17 # Build with -fPIC always
18 set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
19
20 option(run_unittests "set run_unittests to ON to run unittests (default is OFF)" OFF)
21 if ((MSVC) OR (UNIX) OR (LINUX))
22 # Enable coloring by default for Linux, *nix and Windows
23 option(use_coloring "use test coloring (default is ON)" ON)
24 else()
25 option(use_coloring "use test coloring (default is OFF)" OFF)
26 endif()
27 option(abort_on_fail "abort on test failure (default is OFF)" OFF)
28
29 include (CTest)
30 include (CheckIncludeFiles)
31
32 if(${use_coloring})
33 add_definitions(-DUSE_COLORING)
34 endif()
35
36 if(${abort_on_fail})
37 add_definitions(-DCTEST_ABORT_ON_FAIL)
38 endif()
39
40 if (CMAKE_VERSION VERSION_LESS "3.1")
41 if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
42 set (CMAKE_C_FLAGS "--std=c99 ${CMAKE_C_FLAGS}")
43 endif()
44 else()
45 set (CMAKE_C_STANDARD 99)
46 endif()
47
48 if(MSVC)
49 if (WINCE) # Be lax with WEC 2013 compiler
50 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3")
51 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3")
52 # WEC 2013 uses older VS compiler. Build some files as C++ files to resolve C99 related compile issues
53 SET_SOURCE_FILES_PROPERTIES(src/consolelogger.c src/xlogging.c src/map.c adapters/uniqueid_win32.c adapters/httpapi_wince.c src/tlsio_schannel.c src/x509_schannel.c PROPERTIES LANGUAGE CXX)
54 add_definitions(-DWIN32) #WEC 2013
55 ELSE()
56 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
57 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
58
59 endif()
60 elseif(LINUX)
61 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
62 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
63 if(NOT IN_OPENWRT)
64 set (CMAKE_C_FLAGS "-D_POSIX_C_SOURCE=200112L ${CMAKE_C_FLAGS}")
65 endif()
66 endif()
67
68 if (NOT TARGET azure_macro_utils_c)
69 if (EXISTS ${CMAKE_CURRENT_LIST_DIR}/deps/azure-macro-utils-c/CMakeLists.txt)
70 add_subdirectory(deps/azure-macro-utils-c)
71 else()
72 message(FATAL_ERROR "Could not find azure_macro_utils_c")
73 endif()
74 endif()
75
76 include_directories(${MACRO_UTILS_INC_FOLDER})
77
78 set(ctest_c_files
79 ./src/ctest.c
80 )
81
82 set(ctest_h_files
83 ./inc/ctest.h
84 )
85
86 if (MSVC)
87 set(ctest_c_files
88 ${ctest_c_files}
89 ./src/ctest_windows.c
90 )
91
92 set(ctest_h_files
93 ${ctest_h_files}
94 ./inc/ctest_windows.h
95 )
96 endif()
97
98 #these are the include folders
99 #the following "set" statetement exports across the project a global variable called CTEST_INC_FOLDER that expands to whatever needs to included when using ctest library
100 set(CTEST_INC_FOLDER ${CMAKE_CURRENT_LIST_DIR}/inc CACHE INTERNAL "this is what needs to be included if using ctest lib" FORCE)
101
102 include_directories(${CTEST_INC_FOLDER})
103
104 CHECK_INCLUDE_FILES(stdint.h HAVE_STDINT_H)
105 CHECK_INCLUDE_FILES(stdbool.h HAVE_STDBOOL_H)
106
107 if ((NOT HAVE_STDINT_H) OR (NOT HAVE_STDBOOL_H))
108 include_directories(${CTEST_INC_FOLDER}/aux_inc)
109 endif()
110
111 IF(WIN32)
112 #windows needs this define
113 add_definitions(-D_CRT_SECURE_NO_WARNINGS)
114 ENDIF(WIN32)
115
116 add_library(
117 ctest ${ctest_c_files} ${ctest_h_files}
118 )
119
120 target_include_directories(ctest
121 PUBLIC
122 $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/inc>
123 $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
124 )
125
126 set_target_properties(ctest
127 PROPERTIES
128 FOLDER "test_tools")
129
130 if (${run_unittests})
131 add_subdirectory(tests)
132 endif()
133
134 # Set CMAKE_INSTALL_* if not defined
135 include(GNUInstallDirs)
136
137 if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
138 set(CMAKE_INSTALL_LIBDIR "lib")
139 endif()
140
141 # Install Azure CTest
142 set(package_location "cmake")
143
144 install (TARGETS ctest EXPORT ctestTargets
145 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
146 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
147 RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}/../bin
148 INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
149 )
150 install (FILES ${ctest_h_files} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
151
152 include(CMakePackageConfigHelpers)
153
154 write_basic_package_version_file(
155 "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}ConfigVersion.cmake"
156 VERSION ${CTEST_VERSION}
157 COMPATIBILITY SameMajorVersion
158 )
159
160 configure_file("configs/${PROJECT_NAME}Config.cmake"
161 "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}Config.cmake"
162 COPYONLY
163 )
164
165 install(EXPORT ctestTargets
166 FILE
167 "${PROJECT_NAME}Targets.cmake"
168 DESTINATION
169 ${package_location}
170 )
171 install(
172 FILES
173 "configs/${PROJECT_NAME}Config.cmake"
174 "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}ConfigVersion.cmake"
175 DESTINATION
176 ${package_location}
177 )