forked from openzfs/zfs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
97 lines (81 loc) · 3.1 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
cmake_minimum_required(VERSION 3.13)
project(OpenZFS LANGUAGES C CXX ASM)
SET (CMAKE_ASM_COMPILER_ID Clang)
SET (CMAKE_ASM_COMPILER clang-cl.exe)
include(GNUInstallDirs)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/contrib/windows/cmake")
find_package(WDK REQUIRED)
option(BUILD_SHARED_LIBS "Build Shared Libraries" OFF)
set(OPENSSL_USE_STATIC_LIBS TRUE)
set(OPENSSL_MSVC_STATIC_RT TRUE)
find_package(OpenSSL REQUIRED)
# message(STATUS "OpenSSL libs: " ${OPENSSL_LIBRARIES})
# Seriously, why does it pick MD versions and not MT like requested?
# string(REGEX REPLACE "64MD" "64MT" INTERNAL_OPENSSL_LIBRARIES ${OPENSSL_LIBRARIES})
#message(STATUS "OpenSSL libs: " ${OPENSSL_CRYPTO_LIBRARY})
#cmake_path(GET ${OPENSSL_LIBRARIES} ROOT_PATH rootPath)
#get_filename_component(rootPath "${OPENSSL_CRYPTO_LIBRARY}" DIRECTORY)
#message(STATUS "OpenSSL root: " ${rootPath})
# Attempt to simulate scripts/make-gitrev.h and zfs_gitrev.h
include(GetGitRevisionDescription)
include(GetGitRevisionDescription)
git_describe_working_tree(GIT_GITREV)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/include/zfs_gitrev.h.win" "${CMAKE_CURRENT_SOURCE_DIR}/include/zfs_gitrev.h" @ONLY)
#
function(use_clang)
# It seems "-include file" is "/FI file" on Windows
add_compile_options(/FI ${CMAKE_SOURCE_DIR}/include/os/windows/zfs/zfs_config.h)
set(CMAKE_C_COMPILER clang-cl.exe PARENT_SCOPE)
set(CMAKE_CXX_COMPILER clang-cl.exe PARENT_SCOPE)
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
add_compile_options(-m32)
else()
add_compile_options(-m64)
endif()
add_compile_options(
# These are all MS headers
-Wno-nonportable-include-path
-Wno-unknown-pragmas
-Wno-ignored-pragma-intrinsic
-Wno-pragma-pack
-Wno-microsoft-enum-forward-reference
-Wno-visibility
-Wno-microsoft-anon-tag
# -Wno-ignored-attributes
-Wno-unused-command-line-argument
-Wno-unused-local-typedef
-Wno-int-to-void-pointer-cast
# ZFS related
-Wno-misleading-indentation
-Wno-dangling-else
-Wno-missing-field-initializers
#-fms-extensions
-Wno-unused-function
-Wno-unused-label
#Visual Studio 2022 update 2022114 started breaking builds with errors
-Wno-int-conversion
)
endfunction()
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
add_definitions(-D__x86_32__ -D__i386 -D__i386__ -D_LP32 -DWIN32)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
add_definitions(-D__x86_64__ -D_LP64 -D__LP64__ -D__x86_64 -D_AMD64_ -D_WIN64 -DAMD64 -DWIN64)
else()
message(FATAL_ERROR "Unsupported architecture")
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-DDBG -DZFS_DEBUG)
endif()
# Avoid dependency add_compile_definitions vcruntime140.dll
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
# Let's try to emulate gitrev
#find_path(BASH_DIR NAMES bash.exe git-bash.exe PATHS "/c/Program Files (x86)/Git/")
#execute_process(COMMAND $BASH_DIR -c "scripts/make_gitrev.h include/zfs_gitrev.h" )
add_subdirectory(module)
#add_subdirectory(module/zfs)
#add_subdirectory(zfsinstaller)
add_subdirectory(lib)
add_subdirectory(cmd)