| 1 |
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying |
| 2 |
# file Copyright.txt or https://cmake.org/licensing#kwsys for details. |
| 3 |
|
| 4 |
# The Kitware System Library is intended to be included in other |
| 5 |
# projects. It is completely configurable in that the library's |
| 6 |
# namespace can be configured and the components that are included can |
| 7 |
# be selected invididually. |
| 8 |
|
| 9 |
# Typical usage is to import the kwsys directory tree into a |
| 10 |
# subdirectory under a parent project and enable the classes that will |
| 11 |
# be used. All classes are disabled by default. The CMake listfile |
| 12 |
# above this one configures the library as follows: |
| 13 |
# |
| 14 |
# set(KWSYS_NAMESPACE foosys) |
| 15 |
# set(KWSYS_USE_Directory 1) # Enable Directory class. |
| 16 |
# add_subdirectory(kwsys) |
| 17 |
# |
| 18 |
# Optional settings are as follows: |
| 19 |
# |
| 20 |
# KWSYS_HEADER_ROOT = The directory into which to generate the kwsys headers. |
| 21 |
# A directory called "${KWSYS_NAMESPACE}" will be |
| 22 |
# created under this root directory to hold the files. |
| 23 |
# KWSYS_SPLIT_OBJECTS_FROM_INTERFACE |
| 24 |
# = Instead of creating a single ${KWSYS_NAMESPACE} library |
| 25 |
# target, create three separate targets: |
| 26 |
# ${KWSYS_NAMESPACE} |
| 27 |
# - An INTERFACE library only containing usage |
| 28 |
# requirements. |
| 29 |
# ${KWSYS_NAMESPACE}_objects |
| 30 |
# - An OBJECT library for the built kwsys objects. |
| 31 |
# Note: This is omitted from the install rules |
| 32 |
# ${KWSYS_NAMESPACE}_private |
| 33 |
# - An INTERFACE library combining both that is |
| 34 |
# appropriate for use with PRIVATE linking in |
| 35 |
# target_link_libraries. Because of how interface |
| 36 |
# properties propagate, this target is not suitable |
| 37 |
# for use with PUBLIC or INTERFACE linking. |
| 38 |
# KWSYS_ALIAS_TARGET = The name of an alias target to create to the actual target. |
| 39 |
# |
| 40 |
# Example: |
| 41 |
# |
| 42 |
# set(KWSYS_HEADER_ROOT ${PROJECT_BINARY_DIR}) |
| 43 |
# include_directories(${PROJECT_BINARY_DIR}) |
| 44 |
# |
| 45 |
# KWSYS_CXX_STANDARD = A value for CMAKE_CXX_STANDARD within KWSys. |
| 46 |
# Set to empty string to use no default value. |
| 47 |
# KWSYS_CXX_COMPILE_FEATURES = target_compile_features arguments for KWSys. |
| 48 |
# |
| 49 |
# KWSYS_NO_EXECINFO = Do not use execinfo. |
| 50 |
# |
| 51 |
# Optional settings to setup install rules are as follows: |
| 52 |
# |
| 53 |
# KWSYS_INSTALL_BIN_DIR = The installation target directories into |
| 54 |
# KWSYS_INSTALL_LIB_DIR which the libraries and headers from |
| 55 |
# KWSYS_INSTALL_INCLUDE_DIR kwsys should be installed by a "make install". |
| 56 |
# The values should be specified relative to |
| 57 |
# the installation prefix and NOT start with '/'. |
| 58 |
# KWSYS_INSTALL_DOC_DIR = The installation target directory for documentation |
| 59 |
# such as copyright information. |
| 60 |
# |
| 61 |
# KWSYS_INSTALL_COMPONENT_NAME_RUNTIME = Name of runtime and development |
| 62 |
# KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT installation components. |
| 63 |
# If not given the install rules |
| 64 |
# will not be in any component. |
| 65 |
# |
| 66 |
# KWSYS_INSTALL_EXPORT_NAME = The EXPORT option value for install(TARGETS) calls. |
| 67 |
# |
| 68 |
# Example: |
| 69 |
# |
| 70 |
# set(KWSYS_INSTALL_BIN_DIR bin) |
| 71 |
# set(KWSYS_INSTALL_LIB_DIR lib) |
| 72 |
# set(KWSYS_INSTALL_INCLUDE_DIR include) |
| 73 |
# set(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME Runtime) |
| 74 |
# set(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT Development) |
| 75 |
|
| 76 |
# Once configured, kwsys should be used as follows from C or C++ code: |
| 77 |
# |
| 78 |
# #include <foosys/Directory.hxx> |
| 79 |
# ... |
| 80 |
# foosys::Directory directory; |
| 81 |
# |
| 82 |
|
| 83 |
# NOTE: This library is intended for internal use by Kitware-driven |
| 84 |
# projects. In order to keep it simple no attempt will be made to |
| 85 |
# maintain backward compatibility when changes are made to KWSys. |
| 86 |
# When an incompatible change is made Kitware's projects that use |
| 87 |
# KWSys will be fixed, but no notification will necessarily be sent to |
| 88 |
# any outside mailing list and no documentation of the change will be |
| 89 |
# written. |
| 90 |
|
| 91 |
cmake_minimum_required(VERSION 3.9...3.22 FATAL_ERROR) |
| 92 |
|
| 93 |
# Some configure checks depend upon the deployment target. Clear checks when |
| 94 |
# the deployment target changes. |
| 95 |
if (APPLE) |
| 96 |
if (NOT CMAKE_OSX_DEPLOYMENT_TARGET STREQUAL KWSYS_LAST_OSX_DEPLOYMENT_TARGET) |
| 97 |
unset(KWSYS_CXX_HAS_UTIMENSAT CACHE) |
| 98 |
endif () |
| 99 |
set(KWSYS_LAST_OSX_DEPLOYMENT_TARGET "${CMAKE_OSX_DEPLOYMENT_TARGET}" |
| 100 |
CACHE INTERNAL "remember the last deployment target to trigger configure rechecks") |
| 101 |
endif () |
| 102 |
|
| 103 |
#----------------------------------------------------------------------------- |
| 104 |
# If a namespace is not specified, use "kwsys" and enable testing. |
| 105 |
# This should be the case only when kwsys is not included inside |
| 106 |
# another project and is being tested. |
| 107 |
if(NOT KWSYS_NAMESPACE) |
| 108 |
set(KWSYS_NAMESPACE "kwsys") |
| 109 |
set(KWSYS_STANDALONE 1) |
| 110 |
endif() |
| 111 |
|
| 112 |
#----------------------------------------------------------------------------- |
| 113 |
# The project name is that of the specified namespace. |
| 114 |
project(${KWSYS_NAMESPACE}) |
| 115 |
|
| 116 |
# Tell CMake how to follow dependencies of sources in this directory. |
| 117 |
set_property(DIRECTORY |
| 118 |
PROPERTY IMPLICIT_DEPENDS_INCLUDE_TRANSFORM |
| 119 |
"KWSYS_HEADER(%)=<${KWSYS_NAMESPACE}/%>" |
| 120 |
) |
| 121 |
|
| 122 |
if(KWSYS_CXX_STANDARD) |
| 123 |
set(CMAKE_CXX_STANDARD "${KWSYS_CXX_STANDARD}") |
| 124 |
elseif(NOT DEFINED CMAKE_CXX_STANDARD AND NOT DEFINED KWSYS_CXX_STANDARD) |
| 125 |
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" |
| 126 |
AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC" |
| 127 |
AND CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU" |
| 128 |
) |
| 129 |
set(CMAKE_CXX_STANDARD 14) |
| 130 |
else() |
| 131 |
set(CMAKE_CXX_STANDARD 11) |
| 132 |
endif() |
| 133 |
endif() |
| 134 |
|
| 135 |
# Select library components. |
| 136 |
if(KWSYS_STANDALONE OR CMake_SOURCE_DIR) |
| 137 |
set(KWSYS_ENABLE_C 1) |
| 138 |
# Enable all components. |
| 139 |
set(KWSYS_USE_Base64 1) |
| 140 |
set(KWSYS_USE_Directory 1) |
| 141 |
set(KWSYS_USE_DynamicLoader 1) |
| 142 |
set(KWSYS_USE_Encoding 1) |
| 143 |
set(KWSYS_USE_Glob 1) |
| 144 |
set(KWSYS_USE_MD5 1) |
| 145 |
set(KWSYS_USE_Process 1) |
| 146 |
set(KWSYS_USE_RegularExpression 1) |
| 147 |
set(KWSYS_USE_Status 1) |
| 148 |
set(KWSYS_USE_System 1) |
| 149 |
set(KWSYS_USE_SystemTools 1) |
| 150 |
set(KWSYS_USE_CommandLineArguments 1) |
| 151 |
set(KWSYS_USE_Terminal 1) |
| 152 |
set(KWSYS_USE_FStream 1) |
| 153 |
set(KWSYS_USE_String 1) |
| 154 |
set(KWSYS_USE_SystemInformation 1) |
| 155 |
set(KWSYS_USE_ConsoleBuf 1) |
| 156 |
endif() |
| 157 |
|
| 158 |
# Enforce component dependencies. |
| 159 |
if(KWSYS_USE_SystemTools) |
| 160 |
set(KWSYS_USE_Directory 1) |
| 161 |
set(KWSYS_USE_FStream 1) |
| 162 |
set(KWSYS_USE_Encoding 1) |
| 163 |
set(KWSYS_USE_Status 1) |
| 164 |
endif() |
| 165 |
if(KWSYS_USE_Glob) |
| 166 |
set(KWSYS_USE_Directory 1) |
| 167 |
set(KWSYS_USE_SystemTools 1) |
| 168 |
set(KWSYS_USE_RegularExpression 1) |
| 169 |
set(KWSYS_USE_FStream 1) |
| 170 |
set(KWSYS_USE_Encoding 1) |
| 171 |
endif() |
| 172 |
if(KWSYS_USE_Process) |
| 173 |
set(KWSYS_USE_System 1) |
| 174 |
set(KWSYS_USE_Encoding 1) |
| 175 |
endif() |
| 176 |
if(KWSYS_USE_SystemInformation) |
| 177 |
set(KWSYS_USE_Process 1) |
| 178 |
endif() |
| 179 |
if(KWSYS_USE_System) |
| 180 |
set(KWSYS_USE_Encoding 1) |
| 181 |
endif() |
| 182 |
if(KWSYS_USE_Directory) |
| 183 |
set(KWSYS_USE_Encoding 1) |
| 184 |
set(KWSYS_USE_Status 1) |
| 185 |
set(KWSYS_USE_SystemTools 1) |
| 186 |
endif() |
| 187 |
if(KWSYS_USE_DynamicLoader) |
| 188 |
set(KWSYS_USE_Encoding 1) |
| 189 |
endif() |
| 190 |
if(KWSYS_USE_FStream) |
| 191 |
set(KWSYS_USE_Encoding 1) |
| 192 |
endif() |
| 193 |
if(KWSYS_USE_ConsoleBuf) |
| 194 |
set(KWSYS_USE_Encoding 1) |
| 195 |
endif() |
| 196 |
|
| 197 |
# Specify default 8 bit encoding for Windows |
| 198 |
if(NOT KWSYS_ENCODING_DEFAULT_CODEPAGE) |
| 199 |
set(KWSYS_ENCODING_DEFAULT_CODEPAGE CP_ACP) |
| 200 |
endif() |
| 201 |
|
| 202 |
# Enable testing if building standalone. |
| 203 |
if(KWSYS_STANDALONE) |
| 204 |
include(CTest) |
| 205 |
endif() |
| 206 |
|
| 207 |
# Choose default shared/static build if not specified. |
| 208 |
if(NOT DEFINED KWSYS_BUILD_SHARED) |
| 209 |
set(KWSYS_BUILD_SHARED ${BUILD_SHARED_LIBS}) |
| 210 |
endif() |
| 211 |
|
| 212 |
# Include helper macros. |
| 213 |
include(${CMAKE_CURRENT_SOURCE_DIR}/kwsysPlatformTests.cmake) |
| 214 |
include(CheckTypeSize) |
| 215 |
|
| 216 |
# Do full dependency headers. |
| 217 |
include_regular_expression("^.*$") |
| 218 |
|
| 219 |
# Use new KWSYS_INSTALL_*_DIR variable names to control installation. |
| 220 |
# Take defaults from the old names. Note that there was no old name |
| 221 |
# for the bin dir, so we take the old lib dir name so DLLs will be |
| 222 |
# installed in a compatible way for old code. |
| 223 |
if(NOT KWSYS_INSTALL_INCLUDE_DIR) |
| 224 |
string(REGEX REPLACE "^/" "" KWSYS_INSTALL_INCLUDE_DIR |
| 225 |
"${KWSYS_HEADER_INSTALL_DIR}") |
| 226 |
endif() |
| 227 |
if(NOT KWSYS_INSTALL_LIB_DIR) |
| 228 |
string(REGEX REPLACE "^/" "" KWSYS_INSTALL_LIB_DIR |
| 229 |
"${KWSYS_LIBRARY_INSTALL_DIR}") |
| 230 |
endif() |
| 231 |
if(NOT KWSYS_INSTALL_BIN_DIR) |
| 232 |
string(REGEX REPLACE "^/" "" KWSYS_INSTALL_BIN_DIR |
| 233 |
"${KWSYS_LIBRARY_INSTALL_DIR}") |
| 234 |
endif() |
| 235 |
|
| 236 |
# Setup header install rules. |
| 237 |
set(KWSYS_INSTALL_INCLUDE_OPTIONS) |
| 238 |
if(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT) |
| 239 |
set(KWSYS_INSTALL_INCLUDE_OPTIONS ${KWSYS_INSTALL_INCLUDE_OPTIONS} |
| 240 |
COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT} |
| 241 |
) |
| 242 |
endif() |
| 243 |
|
| 244 |
# Setup library install rules. |
| 245 |
set(KWSYS_INSTALL_LIBRARY_RULE) |
| 246 |
set(KWSYS_INSTALL_NAMELINK_RULE) |
| 247 |
if(KWSYS_INSTALL_LIB_DIR) |
| 248 |
if(KWSYS_INSTALL_EXPORT_NAME) |
| 249 |
list(APPEND KWSYS_INSTALL_LIBRARY_RULE EXPORT ${KWSYS_INSTALL_EXPORT_NAME}) |
| 250 |
endif() |
| 251 |
# Install the shared library to the lib directory. |
| 252 |
set(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE} |
| 253 |
LIBRARY DESTINATION ${KWSYS_INSTALL_LIB_DIR} NAMELINK_SKIP |
| 254 |
) |
| 255 |
# Assign the shared library to the runtime component. |
| 256 |
if(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME) |
| 257 |
set(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE} |
| 258 |
COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_RUNTIME} |
| 259 |
) |
| 260 |
endif() |
| 261 |
if(KWSYS_BUILD_SHARED) |
| 262 |
set(KWSYS_INSTALL_NAMELINK_RULE ${KWSYS_INSTALL_NAMELINK_RULE} |
| 263 |
LIBRARY DESTINATION ${KWSYS_INSTALL_LIB_DIR} NAMELINK_ONLY |
| 264 |
) |
| 265 |
# Assign the namelink to the development component. |
| 266 |
if(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT) |
| 267 |
set(KWSYS_INSTALL_NAMELINK_RULE ${KWSYS_INSTALL_NAMELINK_RULE} |
| 268 |
COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT} |
| 269 |
) |
| 270 |
endif() |
| 271 |
endif() |
| 272 |
|
| 273 |
# Install the archive to the lib directory. |
| 274 |
set(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE} |
| 275 |
ARCHIVE DESTINATION ${KWSYS_INSTALL_LIB_DIR} |
| 276 |
) |
| 277 |
# Assign the archive to the development component. |
| 278 |
if(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT) |
| 279 |
set(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE} |
| 280 |
COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT} |
| 281 |
) |
| 282 |
endif() |
| 283 |
endif() |
| 284 |
if(KWSYS_INSTALL_BIN_DIR) |
| 285 |
# Install the runtime library to the bin directory. |
| 286 |
set(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE} |
| 287 |
RUNTIME DESTINATION ${KWSYS_INSTALL_BIN_DIR} |
| 288 |
) |
| 289 |
# Assign the runtime library to the runtime component. |
| 290 |
if(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME) |
| 291 |
set(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE} |
| 292 |
COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_RUNTIME} |
| 293 |
) |
| 294 |
endif() |
| 295 |
endif() |
| 296 |
|
| 297 |
# Do not support old KWSYS_*a_INSTALL_DIR variable names. |
| 298 |
set(KWSYS_HEADER_INSTALL_DIR) |
| 299 |
set(KWSYS_LIBRARY_INSTALL_DIR) |
| 300 |
|
| 301 |
# Select plugin module file name convention. |
| 302 |
if(NOT KWSYS_DynamicLoader_PREFIX) |
| 303 |
set(KWSYS_DynamicLoader_PREFIX ${CMAKE_SHARED_MODULE_PREFIX}) |
| 304 |
endif() |
| 305 |
if(NOT KWSYS_DynamicLoader_SUFFIX) |
| 306 |
set(KWSYS_DynamicLoader_SUFFIX ${CMAKE_SHARED_MODULE_SUFFIX}) |
| 307 |
endif() |
| 308 |
|
| 309 |
#----------------------------------------------------------------------------- |
| 310 |
# We require ANSI support from the C compiler. Add any needed flags. |
| 311 |
if(CMAKE_ANSI_CFLAGS) |
| 312 |
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_ANSI_CFLAGS}") |
| 313 |
endif() |
| 314 |
|
| 315 |
#----------------------------------------------------------------------------- |
| 316 |
# Adjust compiler flags for some platforms. |
| 317 |
if(NOT CMAKE_COMPILER_IS_GNUCXX) |
| 318 |
if(CMAKE_SYSTEM MATCHES "OSF1-V.*") |
| 319 |
string(REGEX MATCH "-timplicit_local" |
| 320 |
KWSYS_CXX_FLAGS_HAVE_IMPLICIT_LOCAL "${CMAKE_CXX_FLAGS}") |
| 321 |
string(REGEX MATCH "-no_implicit_include" |
| 322 |
KWSYS_CXX_FLAGS_HAVE_NO_IMPLICIT_INCLUDE "${CMAKE_CXX_FLAGS}") |
| 323 |
if(NOT KWSYS_CXX_FLAGS_HAVE_IMPLICIT_LOCAL) |
| 324 |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -timplicit_local") |
| 325 |
endif() |
| 326 |
if(NOT KWSYS_CXX_FLAGS_HAVE_NO_IMPLICIT_INCLUDE) |
| 327 |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -no_implicit_include") |
| 328 |
endif() |
| 329 |
endif() |
| 330 |
if(CMAKE_SYSTEM MATCHES "HP-UX") |
| 331 |
set(KWSYS_PLATFORM_CXX_TEST_EXTRA_FLAGS "+p") |
| 332 |
if(CMAKE_CXX_COMPILER_ID MATCHES "HP") |
| 333 |
# it is known that version 3.85 fails and 6.25 works without these flags |
| 334 |
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4) |
| 335 |
# use new C++ library and improved template support |
| 336 |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -AA +hpxstd98") |
| 337 |
endif() |
| 338 |
endif() |
| 339 |
endif() |
| 340 |
endif() |
| 341 |
if(KWSYS_STANDALONE) |
| 342 |
if(CMAKE_CXX_COMPILER_ID STREQUAL SunPro) |
| 343 |
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13) |
| 344 |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++03") |
| 345 |
else() |
| 346 |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -library=stlport4") |
| 347 |
endif() |
| 348 |
endif() |
| 349 |
endif() |
| 350 |
|
| 351 |
#----------------------------------------------------------------------------- |
| 352 |
# Configure the standard library header wrappers based on compiler's |
| 353 |
# capabilities and parent project's request. Enforce 0/1 as only |
| 354 |
# possible values for configuration into Configure.hxx. |
| 355 |
|
| 356 |
if(KWSYS_USE_Encoding) |
| 357 |
# Look for type size helper macros. |
| 358 |
KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_WSTRING |
| 359 |
"Checking whether wstring is available" DIRECT) |
| 360 |
endif() |
| 361 |
|
| 362 |
if(KWSYS_NAMESPACE MATCHES "^kwsys$") |
| 363 |
set(KWSYS_NAME_IS_KWSYS 1) |
| 364 |
else() |
| 365 |
set(KWSYS_NAME_IS_KWSYS 0) |
| 366 |
endif() |
| 367 |
|
| 368 |
if(KWSYS_BUILD_SHARED) |
| 369 |
set(KWSYS_BUILD_SHARED 1) |
| 370 |
set(KWSYS_LIBRARY_TYPE SHARED) |
| 371 |
else() |
| 372 |
set(KWSYS_BUILD_SHARED 0) |
| 373 |
set(KWSYS_LIBRARY_TYPE STATIC) |
| 374 |
endif() |
| 375 |
|
| 376 |
if(NOT DEFINED KWSYS_BUILD_PIC) |
| 377 |
set(KWSYS_BUILD_PIC 0) |
| 378 |
endif() |
| 379 |
|
| 380 |
#----------------------------------------------------------------------------- |
| 381 |
# Configure some implementation details. |
| 382 |
|
| 383 |
KWSYS_PLATFORM_C_TEST(KWSYS_C_HAS_PTRDIFF_T |
| 384 |
"Checking whether C compiler has ptrdiff_t in stddef.h" DIRECT) |
| 385 |
KWSYS_PLATFORM_C_TEST(KWSYS_C_HAS_SSIZE_T |
| 386 |
"Checking whether C compiler has ssize_t in unistd.h" DIRECT) |
| 387 |
if(KWSYS_USE_Process) |
| 388 |
KWSYS_PLATFORM_C_TEST(KWSYS_C_HAS_CLOCK_GETTIME_MONOTONIC |
| 389 |
"Checking whether C compiler has clock_gettime" DIRECT) |
| 390 |
endif() |
| 391 |
|
| 392 |
set_source_files_properties(ProcessUNIX.c System.c PROPERTIES |
| 393 |
COMPILE_FLAGS "-DKWSYS_C_HAS_PTRDIFF_T=${KWSYS_C_HAS_PTRDIFF_T} -DKWSYS_C_HAS_SSIZE_T=${KWSYS_C_HAS_SSIZE_T} -DKWSYS_C_HAS_CLOCK_GETTIME_MONOTONIC=${KWSYS_C_HAS_CLOCK_GETTIME_MONOTONIC}" |
| 394 |
) |
| 395 |
|
| 396 |
if(DEFINED KWSYS_PROCESS_USE_SELECT) |
| 397 |
get_property(ProcessUNIX_FLAGS SOURCE ProcessUNIX.c PROPERTY COMPILE_FLAGS) |
| 398 |
set_property(SOURCE ProcessUNIX.c PROPERTY COMPILE_FLAGS "${ProcessUNIX_FLAGS} -DKWSYSPE_USE_SELECT=${KWSYSPE_USE_SELECT}") |
| 399 |
endif() |
| 400 |
|
| 401 |
if(KWSYS_USE_DynamicLoader) |
| 402 |
get_property(KWSYS_SUPPORTS_SHARED_LIBS GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS) |
| 403 |
if(KWSYS_SUPPORTS_SHARED_LIBS) |
| 404 |
set(KWSYS_SUPPORTS_SHARED_LIBS 1) |
| 405 |
else() |
| 406 |
set(KWSYS_SUPPORTS_SHARED_LIBS 0) |
| 407 |
endif() |
| 408 |
set_property(SOURCE DynamicLoader.cxx APPEND PROPERTY COMPILE_DEFINITIONS |
| 409 |
KWSYS_SUPPORTS_SHARED_LIBS=${KWSYS_SUPPORTS_SHARED_LIBS}) |
| 410 |
endif() |
| 411 |
|
| 412 |
if(KWSYS_USE_SystemTools) |
| 413 |
if (NOT DEFINED KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP) |
| 414 |
set(KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP 1) |
| 415 |
endif () |
| 416 |
if (KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP) |
| 417 |
set(KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP 1) |
| 418 |
else () |
| 419 |
set(KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP 0) |
| 420 |
endif () |
| 421 |
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_SETENV |
| 422 |
"Checking whether CXX compiler has setenv" DIRECT) |
| 423 |
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_UNSETENV |
| 424 |
"Checking whether CXX compiler has unsetenv" DIRECT) |
| 425 |
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H |
| 426 |
"Checking whether CXX compiler has environ in stdlib.h" DIRECT) |
| 427 |
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_UTIMES |
| 428 |
"Checking whether CXX compiler has utimes" DIRECT) |
| 429 |
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_UTIMENSAT |
| 430 |
"Checking whether CXX compiler has utimensat" DIRECT) |
| 431 |
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_STAT_HAS_ST_MTIM |
| 432 |
"Checking whether CXX compiler struct stat has st_mtim member" DIRECT) |
| 433 |
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_STAT_HAS_ST_MTIMESPEC |
| 434 |
"Checking whether CXX compiler struct stat has st_mtimespec member" DIRECT) |
| 435 |
set_property(SOURCE SystemTools.cxx APPEND PROPERTY COMPILE_DEFINITIONS |
| 436 |
KWSYS_CXX_HAS_SETENV=${KWSYS_CXX_HAS_SETENV} |
| 437 |
KWSYS_CXX_HAS_UNSETENV=${KWSYS_CXX_HAS_UNSETENV} |
| 438 |
KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H=${KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H} |
| 439 |
KWSYS_CXX_HAS_UTIMES=${KWSYS_CXX_HAS_UTIMES} |
| 440 |
KWSYS_CXX_HAS_UTIMENSAT=${KWSYS_CXX_HAS_UTIMENSAT} |
| 441 |
KWSYS_CXX_STAT_HAS_ST_MTIM=${KWSYS_CXX_STAT_HAS_ST_MTIM} |
| 442 |
KWSYS_CXX_STAT_HAS_ST_MTIMESPEC=${KWSYS_CXX_STAT_HAS_ST_MTIMESPEC} |
| 443 |
) |
| 444 |
if(NOT WIN32) |
| 445 |
if(KWSYS_STANDALONE) |
| 446 |
option(KWSYS_SYSTEMTOOLS_SUPPORT_WINDOWS_SLASHES "If true, Windows paths will be supported on Unix as well" ON) |
| 447 |
endif() |
| 448 |
if(KWSYS_SYSTEMTOOLS_SUPPORT_WINDOWS_SLASHES) |
| 449 |
set_property(SOURCE SystemTools.cxx testSystemTools.cxx APPEND PROPERTY COMPILE_DEFINITIONS |
| 450 |
KWSYS_SYSTEMTOOLS_SUPPORT_WINDOWS_SLASHES |
| 451 |
) |
| 452 |
endif() |
| 453 |
endif() |
| 454 |
|
| 455 |
# Disable getpwnam for static linux builds since it depends on shared glibc |
| 456 |
get_property(SHARED_LIBS_SUPPORTED GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS) |
| 457 |
if(CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT SHARED_LIBS_SUPPORTED) |
| 458 |
set_property(SOURCE SystemTools.cxx APPEND PROPERTY COMPILE_DEFINITIONS |
| 459 |
HAVE_GETPWNAM=0 |
| 460 |
) |
| 461 |
endif() |
| 462 |
endif() |
| 463 |
|
| 464 |
if(KWSYS_USE_SystemInformation) |
| 465 |
set_property(SOURCE SystemInformation.cxx APPEND PROPERTY |
| 466 |
COMPILE_DEFINITIONS SIZEOF_VOID_P=${CMAKE_SIZEOF_VOID_P}) |
| 467 |
if(NOT CYGWIN) |
| 468 |
include(CheckIncludeFiles) |
| 469 |
CHECK_INCLUDE_FILES("sys/types.h;ifaddrs.h" KWSYS_SYS_HAS_IFADDRS_H) |
| 470 |
if(KWSYS_SYS_HAS_IFADDRS_H) |
| 471 |
set_property(SOURCE SystemInformation.cxx APPEND PROPERTY |
| 472 |
COMPILE_DEFINITIONS KWSYS_SYS_HAS_IFADDRS_H=1) |
| 473 |
endif() |
| 474 |
endif() |
| 475 |
if(WIN32) |
| 476 |
include(CheckSymbolExists) |
| 477 |
set(CMAKE_REQUIRED_LIBRARIES psapi) |
| 478 |
CHECK_SYMBOL_EXISTS(GetProcessMemoryInfo "windows.h;psapi.h" KWSYS_SYS_HAS_PSAPI) |
| 479 |
unset(CMAKE_REQUIRED_LIBRARIES) |
| 480 |
if(KWSYS_SYS_HAS_PSAPI) |
| 481 |
set_property(SOURCE SystemInformation.cxx APPEND PROPERTY |
| 482 |
COMPILE_DEFINITIONS KWSYS_SYS_HAS_PSAPI=1) |
| 483 |
if(MSVC70 OR MSVC71) |
| 484 |
# Suppress LNK4089: all references to 'PSAPI.DLL' discarded by /OPT:REF |
| 485 |
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /IGNORE:4089") |
| 486 |
endif() |
| 487 |
endif() |
| 488 |
endif() |
| 489 |
if(CMAKE_SYSTEM MATCHES "HP-UX") |
| 490 |
CHECK_INCLUDE_FILES("sys/mpctl.h" KWSYS_SYS_HAS_MPCTL_H) |
| 491 |
if(KWSYS_SYS_HAS_MPCTL_H) |
| 492 |
set_property(SOURCE SystemInformation.cxx APPEND PROPERTY |
| 493 |
COMPILE_DEFINITIONS KWSYS_SYS_HAS_MPCTL_H=1) |
| 494 |
endif() |
| 495 |
endif() |
| 496 |
if(CMAKE_SYSTEM MATCHES "BSD") |
| 497 |
CHECK_INCLUDE_FILES("machine/cpu.h" KWSYS_SYS_HAS_MACHINE_CPU_H) |
| 498 |
if(KWSYS_SYS_HAS_MACHINE_CPU_H) |
| 499 |
set_property(SOURCE SystemInformation.cxx APPEND PROPERTY |
| 500 |
COMPILE_DEFINITIONS KWSYS_SYS_HAS_MACHINE_CPU_H=1) |
| 501 |
endif() |
| 502 |
endif() |
| 503 |
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_RLIMIT64 |
| 504 |
"Checking whether CXX compiler has rlimit64" DIRECT) |
| 505 |
set(KWSYS_PLATFORM_CXX_TEST_DEFINES) |
| 506 |
if(KWSYS_CXX_HAS_RLIMIT64) |
| 507 |
set_property(SOURCE SystemInformation.cxx APPEND PROPERTY |
| 508 |
COMPILE_DEFINITIONS KWSYS_CXX_HAS_RLIMIT64=1) |
| 509 |
endif() |
| 510 |
if(UNIX AND NOT KWSYS_NO_EXECINFO) |
| 511 |
include(CheckIncludeFileCXX) |
| 512 |
# check for simple stack trace |
| 513 |
# usually it's in libc but on FreeBSD |
| 514 |
# it's in libexecinfo |
| 515 |
find_library(EXECINFO_LIB "execinfo") |
| 516 |
mark_as_advanced(EXECINFO_LIB) |
| 517 |
if (NOT EXECINFO_LIB) |
| 518 |
set(EXECINFO_LIB "") |
| 519 |
endif() |
| 520 |
CHECK_INCLUDE_FILE_CXX("execinfo.h" KWSYS_CXX_HAS_EXECINFOH) |
| 521 |
if (KWSYS_CXX_HAS_EXECINFOH) |
| 522 |
# we have the backtrace header check if it |
| 523 |
# can be used with this compiler |
| 524 |
set(KWSYS_PLATFORM_CXX_TEST_LINK_LIBRARIES ${EXECINFO_LIB}) |
| 525 |
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_BACKTRACE |
| 526 |
"Checking whether backtrace works with this C++ compiler" DIRECT) |
| 527 |
set(KWSYS_PLATFORM_CXX_TEST_LINK_LIBRARIES) |
| 528 |
if (KWSYS_CXX_HAS_BACKTRACE) |
| 529 |
# backtrace is supported by this system and compiler. |
| 530 |
# now check for the more advanced capabilities. |
| 531 |
set_property(SOURCE SystemInformation.cxx APPEND PROPERTY |
| 532 |
COMPILE_DEFINITIONS KWSYS_SYSTEMINFORMATION_HAS_BACKTRACE=1) |
| 533 |
# check for symbol lookup using dladdr |
| 534 |
CHECK_INCLUDE_FILE_CXX("dlfcn.h" KWSYS_CXX_HAS_DLFCNH) |
| 535 |
if (KWSYS_CXX_HAS_DLFCNH) |
| 536 |
# we have symbol lookup libraries and headers |
| 537 |
# check if they can be used with this compiler |
| 538 |
set(KWSYS_PLATFORM_CXX_TEST_LINK_LIBRARIES ${CMAKE_DL_LIBS}) |
| 539 |
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_DLADDR |
| 540 |
"Checking whether dladdr works with this C++ compiler" DIRECT) |
| 541 |
set(KWSYS_PLATFORM_CXX_TEST_LINK_LIBRARIES) |
| 542 |
if (KWSYS_CXX_HAS_DLADDR) |
| 543 |
# symbol lookup is supported by this system |
| 544 |
# and compiler. |
| 545 |
set_property(SOURCE SystemInformation.cxx APPEND PROPERTY |
| 546 |
COMPILE_DEFINITIONS KWSYS_SYSTEMINFORMATION_HAS_SYMBOL_LOOKUP=1) |
| 547 |
endif() |
| 548 |
endif() |
| 549 |
# c++ demangling support |
| 550 |
# check for cxxabi headers |
| 551 |
CHECK_INCLUDE_FILE_CXX("cxxabi.h" KWSYS_CXX_HAS_CXXABIH) |
| 552 |
if (KWSYS_CXX_HAS_CXXABIH) |
| 553 |
# check if cxxabi can be used with this |
| 554 |
# system and compiler. |
| 555 |
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_CXXABI |
| 556 |
"Checking whether cxxabi works with this C++ compiler" DIRECT) |
| 557 |
if (KWSYS_CXX_HAS_CXXABI) |
| 558 |
# c++ demangle using cxxabi is supported with |
| 559 |
# this system and compiler |
| 560 |
set_property(SOURCE SystemInformation.cxx APPEND PROPERTY |
| 561 |
COMPILE_DEFINITIONS KWSYS_SYSTEMINFORMATION_HAS_CPP_DEMANGLE=1) |
| 562 |
endif() |
| 563 |
endif() |
| 564 |
# basic backtrace works better with release build |
| 565 |
# don't bother with advanced features for release |
| 566 |
set_property(SOURCE SystemInformation.cxx APPEND PROPERTY |
| 567 |
COMPILE_DEFINITIONS_DEBUG KWSYS_SYSTEMINFORMATION_HAS_DEBUG_BUILD=1) |
| 568 |
set_property(SOURCE SystemInformation.cxx APPEND PROPERTY |
| 569 |
COMPILE_DEFINITIONS_RELWITHDEBINFO KWSYS_SYSTEMINFORMATION_HAS_DEBUG_BUILD=1) |
| 570 |
endif() |
| 571 |
endif() |
| 572 |
endif() |
| 573 |
if(KWSYS_BUILD_SHARED) |
| 574 |
set_property(SOURCE SystemInformation.cxx APPEND PROPERTY |
| 575 |
COMPILE_DEFINITIONS KWSYS_BUILD_SHARED=1) |
| 576 |
endif() |
| 577 |
|
| 578 |
if(UNIX AND NOT CYGWIN) |
| 579 |
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_GETLOADAVG |
| 580 |
"Checking whether CXX compiler has getloadavg" DIRECT) |
| 581 |
if(KWSYS_CXX_HAS_GETLOADAVG) |
| 582 |
set_property(SOURCE SystemInformation.cxx APPEND PROPERTY |
| 583 |
COMPILE_DEFINITIONS KWSYS_CXX_HAS_GETLOADAVG=1) |
| 584 |
endif() |
| 585 |
endif() |
| 586 |
endif() |
| 587 |
|
| 588 |
if(KWSYS_USE_FStream) |
| 589 |
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H |
| 590 |
"Checking whether <ext/stdio_filebuf.h> is available" DIRECT) |
| 591 |
endif() |
| 592 |
|
| 593 |
#----------------------------------------------------------------------------- |
| 594 |
# Choose a directory for the generated headers. |
| 595 |
if(NOT KWSYS_HEADER_ROOT) |
| 596 |
set(KWSYS_HEADER_ROOT "${PROJECT_BINARY_DIR}") |
| 597 |
endif() |
| 598 |
set(KWSYS_HEADER_DIR "${KWSYS_HEADER_ROOT}/${KWSYS_NAMESPACE}") |
| 599 |
include_directories(${KWSYS_HEADER_ROOT}) |
| 600 |
|
| 601 |
#----------------------------------------------------------------------------- |
| 602 |
if(KWSYS_INSTALL_DOC_DIR) |
| 603 |
# Assign the license to the runtime component since it must be |
| 604 |
# distributed with binary forms of this software. |
| 605 |
if(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME) |
| 606 |
set(KWSYS_INSTALL_LICENSE_OPTIONS ${KWSYS_INSTALL_LICENSE_OPTIONS} |
| 607 |
COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_RUNTIME} |
| 608 |
) |
| 609 |
endif() |
| 610 |
|
| 611 |
# Install the license under the documentation directory. |
| 612 |
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt |
| 613 |
DESTINATION ${KWSYS_INSTALL_DOC_DIR}/${KWSYS_NAMESPACE} |
| 614 |
${KWSYS_INSTALL_LICENSE_OPTIONS}) |
| 615 |
endif() |
| 616 |
|
| 617 |
#----------------------------------------------------------------------------- |
| 618 |
# Build a list of classes and headers we need to implement the |
| 619 |
# selected components. Initialize with required components. |
| 620 |
set(KWSYS_CLASSES) |
| 621 |
set(KWSYS_H_FILES Configure) |
| 622 |
set(KWSYS_HXX_FILES Configure) |
| 623 |
|
| 624 |
# Add selected C++ classes. |
| 625 |
set(cppclasses |
| 626 |
Directory DynamicLoader Encoding Glob RegularExpression SystemTools |
| 627 |
CommandLineArguments FStream SystemInformation ConsoleBuf Status |
| 628 |
) |
| 629 |
foreach(cpp IN LISTS cppclasses) |
| 630 |
if(KWSYS_USE_${cpp}) |
| 631 |
# Use the corresponding class. |
| 632 |
set(KWSYS_CLASSES ${KWSYS_CLASSES} ${cpp}) |
| 633 |
|
| 634 |
# Load component-specific CMake code. |
| 635 |
if(EXISTS ${PROJECT_SOURCE_DIR}/kwsys${cpp}.cmake) |
| 636 |
include(${PROJECT_SOURCE_DIR}/kwsys${cpp}.cmake) |
| 637 |
endif() |
| 638 |
endif() |
| 639 |
endforeach() |
| 640 |
|
| 641 |
# Add selected C components. |
| 642 |
foreach(c IN ITEMS |
| 643 |
Process Base64 Encoding MD5 Terminal System String |
| 644 |
) |
| 645 |
if(KWSYS_USE_${c}) |
| 646 |
# Use the corresponding header file. |
| 647 |
set(KWSYS_H_FILES ${KWSYS_H_FILES} ${c}) |
| 648 |
|
| 649 |
# Load component-specific CMake code. |
| 650 |
if(EXISTS ${PROJECT_SOURCE_DIR}/kwsys${c}.cmake) |
| 651 |
include(${PROJECT_SOURCE_DIR}/kwsys${c}.cmake) |
| 652 |
endif() |
| 653 |
endif() |
| 654 |
endforeach() |
| 655 |
|
| 656 |
#----------------------------------------------------------------------------- |
| 657 |
# Build a list of sources for the library based on components that are |
| 658 |
# included. |
| 659 |
set(KWSYS_C_SRCS) |
| 660 |
set(KWSYS_CXX_SRCS) |
| 661 |
|
| 662 |
# Add the proper sources for this platform's Process implementation. |
| 663 |
if(KWSYS_USE_Process) |
| 664 |
if(NOT UNIX) |
| 665 |
# Use the Windows implementation. |
| 666 |
set(KWSYS_C_SRCS ${KWSYS_C_SRCS} ProcessWin32.c) |
| 667 |
else() |
| 668 |
# Use the UNIX implementation. |
| 669 |
set(KWSYS_C_SRCS ${KWSYS_C_SRCS} ProcessUNIX.c) |
| 670 |
endif() |
| 671 |
endif() |
| 672 |
|
| 673 |
# Add selected C sources. |
| 674 |
foreach(c IN ITEMS Base64 Encoding MD5 Terminal System String) |
| 675 |
if(KWSYS_USE_${c}) |
| 676 |
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${c}C.c) |
| 677 |
list(APPEND KWSYS_C_SRCS ${c}C.c) |
| 678 |
else() |
| 679 |
list(APPEND KWSYS_C_SRCS ${c}.c) |
| 680 |
endif() |
| 681 |
endif() |
| 682 |
endforeach() |
| 683 |
|
| 684 |
# Configure headers of C++ classes and construct the list of sources. |
| 685 |
foreach(c IN LISTS KWSYS_CLASSES) |
| 686 |
# Add this source to the list of source files for the library. |
| 687 |
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${c}CXX.cxx) |
| 688 |
list(APPEND KWSYS_CXX_SRCS ${c}CXX.cxx) |
| 689 |
elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${c}.cxx) |
| 690 |
list(APPEND KWSYS_CXX_SRCS ${c}.cxx) |
| 691 |
endif() |
| 692 |
|
| 693 |
# Configure the header for this class. |
| 694 |
configure_file(${PROJECT_SOURCE_DIR}/${c}.hxx.in ${KWSYS_HEADER_DIR}/${c}.hxx |
| 695 |
@ONLY IMMEDIATE) |
| 696 |
set(KWSYS_CXX_SRCS ${KWSYS_CXX_SRCS} ${KWSYS_HEADER_DIR}/${c}.hxx) |
| 697 |
|
| 698 |
# Create an install target for the header. |
| 699 |
if(KWSYS_INSTALL_INCLUDE_DIR) |
| 700 |
install(FILES ${KWSYS_HEADER_DIR}/${c}.hxx |
| 701 |
DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE} |
| 702 |
${KWSYS_INSTALL_INCLUDE_OPTIONS}) |
| 703 |
endif() |
| 704 |
endforeach() |
| 705 |
|
| 706 |
# Configure C headers. |
| 707 |
foreach(h IN LISTS KWSYS_H_FILES) |
| 708 |
# Configure the header into the given directory. |
| 709 |
configure_file(${PROJECT_SOURCE_DIR}/${h}.h.in ${KWSYS_HEADER_DIR}/${h}.h |
| 710 |
@ONLY IMMEDIATE) |
| 711 |
set(KWSYS_C_SRCS ${KWSYS_C_SRCS} ${KWSYS_HEADER_DIR}/${h}.h) |
| 712 |
|
| 713 |
# Create an install target for the header. |
| 714 |
if(KWSYS_INSTALL_INCLUDE_DIR) |
| 715 |
install(FILES ${KWSYS_HEADER_DIR}/${h}.h |
| 716 |
DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE} |
| 717 |
${KWSYS_INSTALL_INCLUDE_OPTIONS}) |
| 718 |
endif() |
| 719 |
endforeach() |
| 720 |
|
| 721 |
# Configure other C++ headers. |
| 722 |
foreach(h IN LISTS KWSYS_HXX_FILES) |
| 723 |
# Configure the header into the given directory. |
| 724 |
configure_file(${PROJECT_SOURCE_DIR}/${h}.hxx.in ${KWSYS_HEADER_DIR}/${h}.hxx |
| 725 |
@ONLY IMMEDIATE) |
| 726 |
set(KWSYS_CXX_SRCS ${KWSYS_CXX_SRCS} ${KWSYS_HEADER_DIR}/${h}.hxx) |
| 727 |
|
| 728 |
# Create an install target for the header. |
| 729 |
if(KWSYS_INSTALL_INCLUDE_DIR) |
| 730 |
install(FILES ${KWSYS_HEADER_DIR}/${h}.hxx |
| 731 |
DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE} |
| 732 |
${KWSYS_INSTALL_INCLUDE_OPTIONS}) |
| 733 |
endif() |
| 734 |
endforeach() |
| 735 |
|
| 736 |
#----------------------------------------------------------------------------- |
| 737 |
# Add the library with the configured name and list of sources. |
| 738 |
if(KWSYS_C_SRCS OR KWSYS_CXX_SRCS) |
| 739 |
if(KWSYS_SPLIT_OBJECTS_FROM_INTERFACE) |
| 740 |
set(KWSYS_TARGET_INTERFACE ${KWSYS_NAMESPACE}) |
| 741 |
set(KWSYS_TARGET_OBJECT ${KWSYS_NAMESPACE}_objects) |
| 742 |
set(KWSYS_TARGET_LINK ${KWSYS_NAMESPACE}_private) |
| 743 |
set(KWSYS_TARGET_INSTALL ${KWSYS_TARGET_INTERFACE} ${KWSYS_TARGET_LINK}) |
| 744 |
set(KWSYS_LINK_DEPENDENCY INTERFACE) |
| 745 |
add_library(${KWSYS_TARGET_OBJECT} OBJECT |
| 746 |
${KWSYS_C_SRCS} ${KWSYS_CXX_SRCS}) |
| 747 |
if(KWSYS_BUILD_SHARED OR KWSYS_BUILD_PIC) |
| 748 |
set_property(TARGET ${KWSYS_TARGET_OBJECT} PROPERTY |
| 749 |
POSITION_INDEPENDENT_CODE TRUE) |
| 750 |
endif() |
| 751 |
add_library(${KWSYS_TARGET_INTERFACE} INTERFACE) |
| 752 |
add_library(${KWSYS_TARGET_LINK} INTERFACE) |
| 753 |
target_link_libraries(${KWSYS_TARGET_LINK} INTERFACE |
| 754 |
${KWSYS_TARGET_INTERFACE}) |
| 755 |
target_sources(${KWSYS_TARGET_LINK} INTERFACE |
| 756 |
$<TARGET_OBJECTS:${KWSYS_TARGET_OBJECT}>) |
| 757 |
target_compile_features(${KWSYS_TARGET_OBJECT} PRIVATE ${KWSYS_CXX_COMPILE_FEATURES}) |
| 758 |
target_compile_features(${KWSYS_TARGET_INTERFACE} INTERFACE ${KWSYS_CXX_COMPILE_FEATURES}) |
| 759 |
else() |
| 760 |
set(KWSYS_TARGET_INTERFACE ${KWSYS_NAMESPACE}) |
| 761 |
set(KWSYS_TARGET_OBJECT ${KWSYS_NAMESPACE}) |
| 762 |
set(KWSYS_TARGET_LINK ${KWSYS_NAMESPACE}) |
| 763 |
set(KWSYS_TARGET_INSTALL ${KWSYS_TARGET_LINK}) |
| 764 |
set(KWSYS_LINK_DEPENDENCY PUBLIC) |
| 765 |
add_library(${KWSYS_TARGET_INTERFACE} ${KWSYS_LIBRARY_TYPE} |
| 766 |
${KWSYS_C_SRCS} ${KWSYS_CXX_SRCS}) |
| 767 |
target_compile_features(${KWSYS_TARGET_INTERFACE} PUBLIC ${KWSYS_CXX_COMPILE_FEATURES}) |
| 768 |
endif() |
| 769 |
if (KWSYS_ALIAS_TARGET) |
| 770 |
add_library(${KWSYS_ALIAS_TARGET} ALIAS ${KWSYS_TARGET_INTERFACE}) |
| 771 |
endif () |
| 772 |
set_target_properties(${KWSYS_TARGET_OBJECT} PROPERTIES |
| 773 |
C_CLANG_TIDY "" |
| 774 |
CXX_CLANG_TIDY "" |
| 775 |
C_INCLUDE_WHAT_YOU_USE "" |
| 776 |
CXX_INCLUDE_WHAT_YOU_USE "" |
| 777 |
LABELS "${KWSYS_LABELS_LIB}") |
| 778 |
if(KWSYS_USE_DynamicLoader) |
| 779 |
if(UNIX) |
| 780 |
target_link_libraries(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY} |
| 781 |
${CMAKE_DL_LIBS}) |
| 782 |
endif() |
| 783 |
endif() |
| 784 |
|
| 785 |
if(KWSYS_USE_SystemInformation) |
| 786 |
if(WIN32) |
| 787 |
target_link_libraries(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY} ws2_32) |
| 788 |
# link in dbghelp.dll for symbol lookup if MSVC 1800 or later |
| 789 |
# Note that the dbghelp runtime is part of MS Windows OS |
| 790 |
if(MSVC_VERSION AND NOT MSVC_VERSION VERSION_LESS 1800) |
| 791 |
target_link_libraries(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY} dbghelp) |
| 792 |
endif() |
| 793 |
if(KWSYS_SYS_HAS_PSAPI) |
| 794 |
target_link_libraries(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY} |
| 795 |
psapi) |
| 796 |
endif() |
| 797 |
elseif(UNIX) |
| 798 |
if (EXECINFO_LIB AND KWSYS_CXX_HAS_BACKTRACE) |
| 799 |
# backtrace on FreeBSD is not in libc |
| 800 |
target_link_libraries(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY} |
| 801 |
${EXECINFO_LIB}) |
| 802 |
endif() |
| 803 |
if (KWSYS_CXX_HAS_DLADDR) |
| 804 |
# for symbol lookup using dladdr |
| 805 |
target_link_libraries(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY} |
| 806 |
${CMAKE_DL_LIBS}) |
| 807 |
endif() |
| 808 |
if (CMAKE_SYSTEM_NAME STREQUAL "SunOS") |
| 809 |
target_link_libraries(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY} |
| 810 |
socket) |
| 811 |
endif() |
| 812 |
endif() |
| 813 |
endif() |
| 814 |
|
| 815 |
# Apply user-defined target properties to the library. |
| 816 |
if(KWSYS_PROPERTIES_CXX) |
| 817 |
set_target_properties(${KWSYS_TARGET_INTERFACE} PROPERTIES |
| 818 |
${KWSYS_PROPERTIES_CXX}) |
| 819 |
endif() |
| 820 |
|
| 821 |
# Set up include usage requirement |
| 822 |
if(COMMAND TARGET_INCLUDE_DIRECTORIES) |
| 823 |
target_include_directories(${KWSYS_TARGET_INTERFACE} INTERFACE |
| 824 |
$<BUILD_INTERFACE:${KWSYS_HEADER_ROOT}>) |
| 825 |
if(KWSYS_INSTALL_INCLUDE_DIR) |
| 826 |
target_include_directories(${KWSYS_TARGET_INTERFACE} INTERFACE |
| 827 |
$<INSTALL_INTERFACE:${KWSYS_INSTALL_INCLUDE_DIR}>) |
| 828 |
endif() |
| 829 |
endif() |
| 830 |
|
| 831 |
# Create an install target for the library. |
| 832 |
if(KWSYS_INSTALL_LIBRARY_RULE) |
| 833 |
install(TARGETS ${KWSYS_TARGET_INSTALL} ${KWSYS_INSTALL_LIBRARY_RULE}) |
| 834 |
endif() |
| 835 |
if(KWSYS_INSTALL_NAMELINK_RULE) |
| 836 |
install(TARGETS ${KWSYS_TARGET_INSTALL} ${KWSYS_INSTALL_NAMELINK_RULE}) |
| 837 |
endif() |
| 838 |
endif() |
| 839 |
|
| 840 |
# Add a C-only library if requested. |
| 841 |
if(KWSYS_ENABLE_C AND KWSYS_C_SRCS) |
| 842 |
if(KWSYS_SPLIT_OBJECTS_FROM_INTERFACE) |
| 843 |
set(KWSYS_TARGET_C_INTERFACE ${KWSYS_NAMESPACE}_c) |
| 844 |
set(KWSYS_TARGET_C_OBJECT ${KWSYS_NAMESPACE}_c_objects) |
| 845 |
set(KWSYS_TARGET_C_LINK ${KWSYS_NAMESPACE}_c_private) |
| 846 |
set(KWSYS_TARGET_C_INSTALL |
| 847 |
${KWSYS_TARGET_C_INTERFACE} ${KWSYS_TARGET_C_LINK}) |
| 848 |
set(KWSYS_LINK_DEPENDENCY INTERFACE) |
| 849 |
add_library(${KWSYS_TARGET_C_OBJECT} OBJECT ${KWSYS_C_SRCS}) |
| 850 |
if(KWSYS_BUILD_SHARED OR KWSYS_BUILD_PIC) |
| 851 |
set_property(TARGET ${KWSYS_TARGET_C_OBJECT} PROPERTY |
| 852 |
POSITION_INDEPENDENT_CODE TRUE) |
| 853 |
endif() |
| 854 |
add_library(${KWSYS_TARGET_C_INTERFACE} INTERFACE) |
| 855 |
add_library(${KWSYS_TARGET_C_LINK} INTERFACE) |
| 856 |
target_link_libraries(${KWSYS_TARGET_C_LINK} INTERFACE |
| 857 |
${KWSYS_TARGET_C_INTERFACE}) |
| 858 |
target_sources(${KWSYS_TARGET_C_LINK} INTERFACE |
| 859 |
$<TARGET_OBJECTS:${KWSYS_TARGET_C_OBJECT}>) |
| 860 |
else() |
| 861 |
set(KWSYS_TARGET_C_INTERFACE ${KWSYS_NAMESPACE}_c) |
| 862 |
set(KWSYS_TARGET_C_OBJECT ${KWSYS_NAMESPACE}_c) |
| 863 |
set(KWSYS_TARGET_C_LINK ${KWSYS_NAMESPACE}_c) |
| 864 |
set(KWSYS_TARGET_C_INSTALL ${KWSYS_TARGET_C_LINK}) |
| 865 |
set(KWSYS_LINK_DEPENDENCY PUBLIC) |
| 866 |
add_library(${KWSYS_TARGET_C_INTERFACE} ${KWSYS_LIBRARY_TYPE} |
| 867 |
${KWSYS_C_SRCS}) |
| 868 |
endif() |
| 869 |
set_target_properties(${KWSYS_TARGET_C_OBJECT} PROPERTIES |
| 870 |
LABELS "${KWSYS_LABELS_LIB}") |
| 871 |
|
| 872 |
# Apply user-defined target properties to the library. |
| 873 |
if(KWSYS_PROPERTIES_C) |
| 874 |
set_target_properties(${KWSYS_TARGET_C_INTERFACE} PROPERTIES |
| 875 |
${KWSYS_PROPERTIES_C}) |
| 876 |
endif() |
| 877 |
|
| 878 |
# Set up include usage requirement |
| 879 |
if(COMMAND TARGET_INCLUDE_DIRECTORIES) |
| 880 |
target_include_directories(${KWSYS_TARGET_C_INTERFACE} INTERFACE |
| 881 |
$<BUILD_INTERFACE:${KWSYS_HEADER_ROOT}>) |
| 882 |
if(KWSYS_INSTALL_INCLUDE_DIR) |
| 883 |
target_include_directories(${KWSYS_TARGET_C_INTERFACE} INTERFACE |
| 884 |
$<INSTALL_INTERFACE:${KWSYS_INSTALL_INCLUDE_DIR}>) |
| 885 |
endif() |
| 886 |
endif() |
| 887 |
|
| 888 |
# Create an install target for the library. |
| 889 |
if(KWSYS_INSTALL_LIBRARY_RULE) |
| 890 |
install(TARGETS ${KWSYS_TARGET_C_INSTALL}) |
| 891 |
endif() |
| 892 |
endif() |
| 893 |
|
| 894 |
# For building kwsys itself, we use a macro defined on the command |
| 895 |
# line to configure the namespace in the C and C++ source files. |
| 896 |
add_definitions("-DKWSYS_NAMESPACE=${KWSYS_NAMESPACE}") |
| 897 |
|
| 898 |
# Disable deprecation warnings for standard C functions. |
| 899 |
if(MSVC OR (WIN32 AND (CMAKE_C_COMPILER_ID STREQUAL "Intel" OR |
| 900 |
(CMAKE_C_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")))) |
| 901 |
add_definitions( |
| 902 |
-D_CRT_NONSTDC_NO_DEPRECATE |
| 903 |
-D_CRT_SECURE_NO_DEPRECATE |
| 904 |
-D_CRT_SECURE_NO_WARNINGS |
| 905 |
-D_SCL_SECURE_NO_DEPRECATE |
| 906 |
) |
| 907 |
endif() |
| 908 |
|
| 909 |
if(WIN32) |
| 910 |
# Help enforce the use of wide Windows apis. |
| 911 |
add_definitions(-DUNICODE -D_UNICODE) |
| 912 |
endif() |
| 913 |
|
| 914 |
if(KWSYS_USE_String) |
| 915 |
# Activate code in "String.c". See the comment in the source. |
| 916 |
set_source_files_properties(String.c PROPERTIES |
| 917 |
COMPILE_FLAGS "-DKWSYS_STRING_C") |
| 918 |
endif() |
| 919 |
|
| 920 |
if(KWSYS_USE_Encoding) |
| 921 |
# Set default 8 bit encoding in "EndcodingC.c". |
| 922 |
set_property(SOURCE EncodingC.c EncodingCXX.cxx APPEND PROPERTY COMPILE_DEFINITIONS |
| 923 |
KWSYS_ENCODING_DEFAULT_CODEPAGE=${KWSYS_ENCODING_DEFAULT_CODEPAGE}) |
| 924 |
endif() |
| 925 |
|
| 926 |
#----------------------------------------------------------------------------- |
| 927 |
# Setup testing if not being built as part of another project. |
| 928 |
if(KWSYS_STANDALONE OR CMake_SOURCE_DIR) |
| 929 |
if(BUILD_TESTING) |
| 930 |
# Compute the location of executables. |
| 931 |
set(EXEC_DIR "${CMAKE_CURRENT_BINARY_DIR}") |
| 932 |
if(CMAKE_RUNTIME_OUTPUT_DIRECTORY) |
| 933 |
set(EXEC_DIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") |
| 934 |
endif() |
| 935 |
|
| 936 |
# C tests |
| 937 |
set(KWSYS_C_TESTS |
| 938 |
testEncode.c |
| 939 |
testTerminal.c |
| 940 |
) |
| 941 |
if(KWSYS_STANDALONE) |
| 942 |
set(KWSYS_C_TESTS ${KWSYS_C_TESTS} testFail.c) |
| 943 |
endif() |
| 944 |
create_test_sourcelist( |
| 945 |
KWSYS_C_TEST_SRCS ${KWSYS_NAMESPACE}TestsC.c |
| 946 |
${KWSYS_C_TESTS} |
| 947 |
) |
| 948 |
add_executable(${KWSYS_NAMESPACE}TestsC ${KWSYS_C_TEST_SRCS}) |
| 949 |
set_property(TARGET ${KWSYS_NAMESPACE}TestsC PROPERTY LABELS ${KWSYS_LABELS_EXE}) |
| 950 |
target_link_libraries(${KWSYS_NAMESPACE}TestsC ${KWSYS_TARGET_C_LINK}) |
| 951 |
foreach(testfile IN LISTS KWSYS_C_TESTS) |
| 952 |
get_filename_component(test "${testfile}" NAME_WE) |
| 953 |
add_test(NAME kwsys.${test} |
| 954 |
COMMAND ${EXEC_DIR}/${KWSYS_NAMESPACE}TestsC ${test} ${KWSYS_TEST_ARGS_${test}} |
| 955 |
) |
| 956 |
set_property(TEST kwsys.${test} PROPERTY LABELS ${KWSYS_LABELS_TEST}) |
| 957 |
endforeach() |
| 958 |
|
| 959 |
# C++ tests |
| 960 |
set(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} |
| 961 |
testConfigure.cxx |
| 962 |
testStatus.cxx |
| 963 |
testSystemTools.cxx |
| 964 |
testCommandLineArguments.cxx |
| 965 |
testCommandLineArguments1.cxx |
| 966 |
testDirectory.cxx |
| 967 |
) |
| 968 |
if(KWSYS_STL_HAS_WSTRING) |
| 969 |
set(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} |
| 970 |
testEncoding.cxx |
| 971 |
) |
| 972 |
endif() |
| 973 |
if(KWSYS_USE_FStream) |
| 974 |
set(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} |
| 975 |
testFStream.cxx |
| 976 |
) |
| 977 |
endif() |
| 978 |
if(KWSYS_USE_ConsoleBuf) |
| 979 |
add_executable(testConsoleBufChild testConsoleBufChild.cxx) |
| 980 |
set_property(TARGET testConsoleBufChild PROPERTY C_CLANG_TIDY "") |
| 981 |
set_property(TARGET testConsoleBufChild PROPERTY CXX_CLANG_TIDY "") |
| 982 |
set_property(TARGET testConsoleBufChild PROPERTY C_INCLUDE_WHAT_YOU_USE "") |
| 983 |
set_property(TARGET testConsoleBufChild PROPERTY CXX_INCLUDE_WHAT_YOU_USE "") |
| 984 |
set_property(TARGET testConsoleBufChild PROPERTY LABELS ${KWSYS_LABELS_EXE}) |
| 985 |
target_link_libraries(testConsoleBufChild ${KWSYS_TARGET_LINK}) |
| 986 |
set(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} |
| 987 |
testConsoleBuf.cxx |
| 988 |
) |
| 989 |
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND |
| 990 |
CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "19.0.23506") |
| 991 |
set_property(SOURCE testConsoleBuf.cxx testConsoleBufChild.cxx PROPERTY COMPILE_FLAGS /utf-8) |
| 992 |
endif() |
| 993 |
set_property(SOURCE testConsoleBuf.cxx APPEND PROPERTY COMPILE_DEFINITIONS |
| 994 |
KWSYS_ENCODING_DEFAULT_CODEPAGE=${KWSYS_ENCODING_DEFAULT_CODEPAGE}) |
| 995 |
endif() |
| 996 |
if(KWSYS_USE_SystemInformation) |
| 997 |
set(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testSystemInformation.cxx) |
| 998 |
endif() |
| 999 |
if(KWSYS_USE_DynamicLoader) |
| 1000 |
set(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testDynamicLoader.cxx) |
| 1001 |
# If kwsys contains the DynamicLoader, need extra library |
| 1002 |
add_library(${KWSYS_NAMESPACE}TestDynload MODULE testDynload.c) |
| 1003 |
set_property(TARGET ${KWSYS_NAMESPACE}TestDynload PROPERTY LABELS ${KWSYS_LABELS_LIB}) |
| 1004 |
add_dependencies(${KWSYS_NAMESPACE}TestDynload ${KWSYS_TARGET_INTERFACE}) |
| 1005 |
|
| 1006 |
if (WIN32) |
| 1007 |
# Windows tests supported flags. |
| 1008 |
add_library(${KWSYS_NAMESPACE}TestDynloadImpl SHARED testDynloadImpl.c) |
| 1009 |
set_property(TARGET ${KWSYS_NAMESPACE}TestDynloadImpl PROPERTY LABELS ${KWSYS_LABELS_LIB}) |
| 1010 |
set_property(TARGET ${KWSYS_NAMESPACE}TestDynloadImpl PROPERTY DEFINE_SYMBOL BUILDING_TestDynloadImpl) |
| 1011 |
set_property(TARGET ${KWSYS_NAMESPACE}TestDynloadImpl PROPERTY RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/dynloaddir") |
| 1012 |
add_dependencies(${KWSYS_NAMESPACE}TestDynloadImpl ${KWSYS_TARGET_INTERFACE}) |
| 1013 |
add_library(${KWSYS_NAMESPACE}TestDynloadUse MODULE testDynloadUse.c) |
| 1014 |
set_property(TARGET ${KWSYS_NAMESPACE}TestDynloadUse PROPERTY LABELS ${KWSYS_LABELS_LIB}) |
| 1015 |
set_property(TARGET ${KWSYS_NAMESPACE}TestDynloadUse PROPERTY LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/dynloaddir") |
| 1016 |
add_dependencies(${KWSYS_NAMESPACE}TestDynloadUse ${KWSYS_TARGET_INTERFACE}) |
| 1017 |
target_link_libraries(${KWSYS_NAMESPACE}TestDynloadUse PRIVATE ${KWSYS_NAMESPACE}TestDynloadImpl) |
| 1018 |
endif () |
| 1019 |
endif() |
| 1020 |
create_test_sourcelist( |
| 1021 |
KWSYS_CXX_TEST_SRCS ${KWSYS_NAMESPACE}TestsCxx.cxx |
| 1022 |
${KWSYS_CXX_TESTS} |
| 1023 |
) |
| 1024 |
add_executable(${KWSYS_NAMESPACE}TestsCxx ${KWSYS_CXX_TEST_SRCS}) |
| 1025 |
set_property(TARGET ${KWSYS_NAMESPACE}TestsCxx PROPERTY C_CLANG_TIDY "") |
| 1026 |
set_property(TARGET ${KWSYS_NAMESPACE}TestsCxx PROPERTY CXX_CLANG_TIDY "") |
| 1027 |
set_property(TARGET ${KWSYS_NAMESPACE}TestsCxx PROPERTY C_INCLUDE_WHAT_YOU_USE "") |
| 1028 |
set_property(TARGET ${KWSYS_NAMESPACE}TestsCxx PROPERTY CXX_INCLUDE_WHAT_YOU_USE "") |
| 1029 |
set_property(TARGET ${KWSYS_NAMESPACE}TestsCxx PROPERTY LABELS ${KWSYS_LABELS_EXE}) |
| 1030 |
target_link_libraries(${KWSYS_NAMESPACE}TestsCxx ${KWSYS_TARGET_LINK}) |
| 1031 |
get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) |
| 1032 |
if(_isMultiConfig) |
| 1033 |
set_property(TARGET ${KWSYS_NAMESPACE}TestsCxx APPEND PROPERTY COMPILE_DEFINITIONS BUILD_CONFIG="$<CONFIG>") |
| 1034 |
endif() |
| 1035 |
|
| 1036 |
set(TEST_SYSTEMTOOLS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") |
| 1037 |
set(TEST_SYSTEMTOOLS_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}") |
| 1038 |
configure_file( |
| 1039 |
${PROJECT_SOURCE_DIR}/testSystemTools.h.in |
| 1040 |
${PROJECT_BINARY_DIR}/testSystemTools.h) |
| 1041 |
include_directories(${PROJECT_BINARY_DIR}) |
| 1042 |
|
| 1043 |
if(CTEST_TEST_KWSYS) |
| 1044 |
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/ExtraTest.cmake.in" |
| 1045 |
"${CMAKE_CURRENT_BINARY_DIR}/ExtraTest.cmake") |
| 1046 |
set_directory_properties(PROPERTIES TEST_INCLUDE_FILE "${CMAKE_CURRENT_BINARY_DIR}/ExtraTest.cmake") |
| 1047 |
endif() |
| 1048 |
|
| 1049 |
set(KWSYS_TEST_ARGS_testCommandLineArguments |
| 1050 |
--another-bool-variable |
| 1051 |
--long3=opt |
| 1052 |
--set-bool-arg1 |
| 1053 |
-SSS ken brad bill andy |
| 1054 |
--some-bool-variable=true |
| 1055 |
--some-double-variable12.5 |
| 1056 |
--some-int-variable 14 |
| 1057 |
"--some-string-variable=test string with space" |
| 1058 |
--some-multi-argument 5 1 8 3 7 1 3 9 7 1 |
| 1059 |
-N 12.5 -SS=andy -N 1.31 -N 22 |
| 1060 |
-SS=bill -BBtrue -SS=brad |
| 1061 |
-BBtrue |
| 1062 |
-BBfalse |
| 1063 |
-SS=ken |
| 1064 |
-A |
| 1065 |
-C=test |
| 1066 |
--long2 hello |
| 1067 |
) |
| 1068 |
set(KWSYS_TEST_ARGS_testCommandLineArguments1 |
| 1069 |
--ignored |
| 1070 |
-n 24 |
| 1071 |
--second-ignored |
| 1072 |
"-m=test value" |
| 1073 |
third-ignored |
| 1074 |
-p |
| 1075 |
some junk at the end |
| 1076 |
) |
| 1077 |
foreach(testfile IN LISTS KWSYS_CXX_TESTS) |
| 1078 |
get_filename_component(test "${testfile}" NAME_WE) |
| 1079 |
add_test(NAME kwsys.${test} |
| 1080 |
COMMAND ${EXEC_DIR}/${KWSYS_NAMESPACE}TestsCxx ${test} ${KWSYS_TEST_ARGS_${test}} |
| 1081 |
) |
| 1082 |
set_property(TEST kwsys.${test} PROPERTY LABELS ${KWSYS_LABELS_TEST}) |
| 1083 |
endforeach() |
| 1084 |
|
| 1085 |
# Process tests. |
| 1086 |
add_executable(${KWSYS_NAMESPACE}TestProcess testProcess.c) |
| 1087 |
set_property(TARGET ${KWSYS_NAMESPACE}TestProcess PROPERTY LABELS ${KWSYS_LABELS_EXE}) |
| 1088 |
target_link_libraries(${KWSYS_NAMESPACE}TestProcess ${KWSYS_TARGET_C_LINK}) |
| 1089 |
#set(KWSYS_TEST_PROCESS_7 7) # uncomment to run timing-sensitive test locally |
| 1090 |
foreach(n IN ITEMS 1 2 3 4 5 6 ${KWSYS_TEST_PROCESS_7} 9 10) |
| 1091 |
add_test(NAME kwsys.testProcess-${n} |
| 1092 |
COMMAND ${EXEC_DIR}/${KWSYS_NAMESPACE}TestProcess ${n} |
| 1093 |
) |
| 1094 |
set_property(TEST kwsys.testProcess-${n} PROPERTY LABELS ${KWSYS_LABELS_TEST}) |
| 1095 |
set_property(TEST kwsys.testProcess-${n} PROPERTY TIMEOUT 120) |
| 1096 |
endforeach() |
| 1097 |
|
| 1098 |
set(testProcess_COMPILE_FLAGS "") |
| 1099 |
# Some Apple compilers produce bad optimizations in this source. |
| 1100 |
if(APPLE AND CMAKE_C_COMPILER_ID MATCHES "^(GNU|LLVM)$") |
| 1101 |
set(testProcess_COMPILE_FLAGS "${testProcess_COMPILE_FLAGS} -O0") |
| 1102 |
elseif(CMAKE_C_COMPILER_ID MATCHES "^(XL|XLClang)$") |
| 1103 |
# Tell IBM XL not to warn about our test infinite loop |
| 1104 |
if(CMAKE_SYSTEM MATCHES "Linux.*ppc64le" |
| 1105 |
AND CMAKE_C_COMPILER_VERSION VERSION_LESS "16.1.0" |
| 1106 |
AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS "13.1.1") |
| 1107 |
# v13.1.[1-6] on Linux ppc64le is clang based and does not accept |
| 1108 |
# the -qsuppress option, so just suppress all warnings. |
| 1109 |
set(testProcess_COMPILE_FLAGS "${testProcess_COMPILE_FLAGS} -w") |
| 1110 |
else() |
| 1111 |
set(testProcess_COMPILE_FLAGS "${testProcess_COMPILE_FLAGS} -qsuppress=1500-010") |
| 1112 |
endif() |
| 1113 |
endif() |
| 1114 |
if(CMAKE_C_FLAGS MATCHES "-fsanitize=") |
| 1115 |
set(testProcess_COMPILE_FLAGS "${testProcess_COMPILE_FLAGS} -DCRASH_USING_ABORT") |
| 1116 |
endif() |
| 1117 |
set_property(SOURCE testProcess.c PROPERTY COMPILE_FLAGS "${testProcess_COMPILE_FLAGS}") |
| 1118 |
|
| 1119 |
# Configure some test properties. |
| 1120 |
if(KWSYS_STANDALONE) |
| 1121 |
# We expect test to fail |
| 1122 |
set_property(TEST kwsys.testFail PROPERTY WILL_FAIL ON) |
| 1123 |
get_test_property(kwsys.testFail WILL_FAIL wfv) |
| 1124 |
set_property(TEST kwsys.testFail PROPERTY MEASUREMENT "Some Key=Some Value") |
| 1125 |
message(STATUS "GET_TEST_PROPERTY returned: ${wfv}") |
| 1126 |
endif() |
| 1127 |
|
| 1128 |
# Set up ctest custom configuration file. |
| 1129 |
configure_file(${PROJECT_SOURCE_DIR}/CTestCustom.cmake.in |
| 1130 |
${PROJECT_BINARY_DIR}/CTestCustom.cmake @ONLY) |
| 1131 |
|
| 1132 |
# Suppress known consistent failures on buggy systems. |
| 1133 |
if(KWSYS_TEST_BOGUS_FAILURES) |
| 1134 |
set_property(TEST ${KWSYS_TEST_BOGUS_FAILURES} PROPERTY WILL_FAIL ON) |
| 1135 |
endif() |
| 1136 |
|
| 1137 |
endif() |
| 1138 |
endif() |