Skip to content

Commit 64b655b

Browse files
committed
some consistency improvements in the cmake files
1 parent d8839ef commit 64b655b

File tree

4 files changed

+24
-13
lines changed

4 files changed

+24
-13
lines changed

cmake_find/Finditslib.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
if (TARGET itslib)
22
return()
33
endif()
4-
find_path(ITSLIB_PATH NAMES include/itslib/stringutils.h PATHS symlinks/itslib)
4+
find_path(ITSLIB_PATH NAMES include/itslib/stringutils.h PATHS ${CMAKE_SOURCE_DIR}/symlinks/itslib)
55
if(ITSLIB_PATH STREQUAL "ITSLIB_PATH-NOTFOUND")
66
include(FetchContent)
77
FetchContent_Populate(itslib

cmake_find/Findopenssl.cmake

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ if (TARGET openssl_ssl)
33
endif()
44
if (DARWIN)
55
find_path(OPENSSL_INCLUDE_PATH NAMES openssl/sha.h
6-
PATHS $ENV{OPENSSL_ROOT_DIR}/include /usr/include /usr/local/include /usr/local/opt/openssl/include)
6+
PATHS $ENV{OPENSSL_ROOT_DIR}/include /usr/local/opt/openssl/include /usr/include /usr/local/include)
77
find_library(OPENSSL_CRYPTO_LIBRARY NAMES crypto
88
PATHS $ENV{OPENSSL_ROOT_DIR}/lib /usr/local/opt/openssl/lib /usr/lib /usr/local/lib)
99
find_library(OPENSSL_SSL_LIBRARY NAMES ssl
@@ -26,7 +26,7 @@ else()
2626
endif()
2727

2828
find_path(OPENSSL_INCLUDE_PATH NAMES openssl/sha.h
29-
PATHS /usr/include /usr/local/include /usr/local/opt/openssl/include)
29+
PATHS /usr/local/opt/openssl/include /usr/include /usr/local/include)
3030
find_library(OPENSSL_CRYPTO_LIBRARY NAMES crypto
3131
PATHS /usr/local/opt/openssl/lib /usr/lib /usr/local/lib)
3232
find_library(OPENSSL_SSL_LIBRARY NAMES ssl

cmake_find/Findzlib.cmake

+17-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
1-
include(FetchContent)
2-
FetchContent_Populate(zlib
3-
# TODO: we need a method of supplying a local cache of this file.
4-
URL https://www.zlib.net/zlib-1.3.tar.gz
5-
URL_HASH SHA256=ff0ba4c292013dbc27530b3a81e1f9a813cd39de01ca5e0f8bf355702efa593e
6-
)
7-
set(ZLIBDIR ${CMAKE_BINARY_DIR}/zlib-src)
1+
find_path(ZLIB_DIR NAMES inftrees.c PATHS ${CMAKE_SOURCE_DIR}/symlinks/zlib)
2+
if(ZLIB_DIR STREQUAL "ZLIB_DIR-NOTFOUND")
3+
include(FetchContent)
4+
FetchContent_Populate(zlib
5+
# TODO: we need a method of supplying a local cache of this file.
6+
URL https://www.zlib.net/zlib-1.3.tar.gz
7+
URL_HASH SHA256=ff0ba4c292013dbc27530b3a81e1f9a813cd39de01ca5e0f8bf355702efa593e
8+
)
9+
set(ZLIB_DIR ${CMAKE_BINARY_DIR}/zlib-src)
10+
else()
11+
set(zlib_BINARY_DIR ${CMAKE_BINARY_DIR}/zlib-build)
12+
endif()
13+
814

915
list(APPEND ZLIBFILES inftrees.c infback.c compress.c inffast.c adler32.c uncompr.c inflate.c deflate.c crc32.c trees.c zutil.c)
1016
#list(APPEND ZLIBFILES gzclose.c gzread.c gzwrite.c gzlib.c) <-- build failure on macos because of missing include <unistd.h>
11-
list(TRANSFORM ZLIBFILES PREPEND ${ZLIBDIR}/)
17+
list(TRANSFORM ZLIBFILES PREPEND ${ZLIB_DIR}/)
1218
add_library(zlib ${LIBSTYLE} ${ZLIBFILES})
13-
target_include_directories(zlib PUBLIC ${ZLIBDIR})
19+
target_include_directories(zlib PUBLIC ${ZLIB_DIR})
1420

21+
include(FindPackageHandleStandardArgs)
22+
find_package_handle_standard_args(zlib REQUIRED_VARS ZLIB_DIR)
1523

cmake_find/boilerplate.cmake

+4-1
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,18 @@ endif()
5454

5555
if (OPT_ANALYZE)
5656
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
57+
# see https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/Static-Analyzer-Options.html#index-analyzer
5758
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fanalyzer")
5859
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
60+
# https://clang.llvm.org/docs/UsersManual.html
5961
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --analyze")
6062
endif()
6163
endif()
6264

6365
if (OPT_ASAN AND OPT_TSAN)
6466
message(FATAL_ERROR "Only one sanitizer can be active at a time")
6567
elseif (OPT_ASAN)
68+
# https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/Instrumentation-Options.html#index-fsanitize_003daddress
6669
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
6770
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
6871
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread")
@@ -160,7 +163,7 @@ if(MSVC)
160163
# NOBITMAP - avoid error in mmreg.h
161164
# NOMINMAX - remove 'max()' macro from global namespace
162165
# NOGDI - ...
163-
add_definitions(-DNOMINMAX -DNOGDI -DNOBITMAP)
166+
add_definitions(-DNOMINMAX -DNOGDI -DNOBITMAP -DWIN32_LEAN_AND_MEAN)
164167
add_definitions(-DWIN32)
165168
add_definitions(-D__STDC_WANT_SECURE_LIB__=1)
166169

0 commit comments

Comments
 (0)