From e5e1946f954e2e258701190547ca1d5602bccd27 Mon Sep 17 00:00:00 2001 From: Naruto TAKAHASHI Date: Thu, 1 Mar 2018 16:59:13 +0900 Subject: [PATCH] targets of Invoking check_include_file changes from all header files to request from options. - `check_include_file(getopt.h HAVE_GETOPT_H )` is invoked when WITH_TOOLS option is ON. - `check_include_file(sys/time.h HAVE_SYS_TIME_H)` is invoked when WITH_TEST option is ON. --- CMakeLists.txt | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f08b2cb5..1d5498f9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,8 +31,18 @@ check_include_file(stdint.h HAVE_STDINT_H ) check_include_file(stdlib.h HAVE_STDLIB_H ) check_include_file(strings.h HAVE_STRINGS_H ) check_include_file(string.h HAVE_STRING_H ) -check_include_file(getopt.h HAVE_GETOPT_H ) -check_include_file(sys/time.h HAVE_SYS_TIME_H) +if(WITH_TOOLS) + if(MSVC) + find_path(GETOPT_INCLUDE_DIR getopt.h PATH_SUFFIXES include) + find_library(GETOPT_LIBRARIES wingetopt PATH_SUFFIXES lib) + include_directories(${GETOPT_INCLUDE_DIR}) + else() + check_include_file(getopt.h HAVE_GETOPT_H) + endif() +endif() +if(WITH_TESTS) + check_include_file(sys/time.h HAVE_SYS_TIME_H) +endif() check_function_exists(strdup HAVE_STRDUP) @@ -70,12 +80,6 @@ if(MSVC) add_definitions(-Dstrncasecmp=_strnicmp) add_definitions(-D_CRT_SECURE_NO_WARNINGS) add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) - - if(WITH_TOOLS) - find_path(GETOPT_INCLUDE_DIR getopt.h PATH_SUFFIXES include) - find_library(GETOPT_LIBRARIES wingetopt PATH_SUFFIXES lib) - include_directories(${GETOPT_INCLUDE_DIR}) - endif(WITH_TOOLS) endif(MSVC) set(QRENCODE_SRCS qrencode.c