forked from sahlberg/libsmb2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
221 lines (202 loc) · 9.58 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
if(NOT ESP_PLATFORM)
if(CMAKE_SYSTEM_NAME MATCHES NintendoSwitch OR CMAKE_SYSTEM_NAME MATCHES Nintendo3DS OR CMAKE_SYSTEM_NAME MATCHES Dreamcast OR CMAKE_SYSTEM_NAME MATCHES NintendoGameCube OR CMAKE_SYSTEM_NAME MATCHES NintendoDS OR CMAKE_SYSTEM_NAME MATCHES NintendoWii OR CMAKE_SYSTEM_NAME MATCHES CafeOS)
cmake_minimum_required(VERSION 3.13)
elseif(VITA)
cmake_minimum_required(VERSION 3.2)
elseif(PICO_BOARD)
cmake_minimum_required(VERSION 3.12)
message(STATUS "Configuring libsmb2 for ${PICO_BOARD}")
else()
cmake_minimum_required(VERSION 3.5)
endif()
if(NOT IOP AND BUILD_IRX)
project(smb2man
LANGUAGES C
VERSION 2.2.0
)
set(VERSION 2.2.0)
set(PACKAGE "smb2man")
set(PACKAGE_BUGREPORT "[email protected] or [email protected]")
set(PACKAGE_NAME "smb2man")
set(PACKAGE_VERSION "${VERSION}")
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set(PACKAGE_TARNAME "${PACKAGE}")
set(PACKAGE_URL "https://github.com/sahlberg/libsmb2")
elseif(PICO_BOARD)
project(libsmb2 C CXX ASM)
else()
project(libsmb2
LANGUAGES C
VERSION 4.0.0
)
set(VERSION 4.0.0)
set(PACKAGE "libsmb2")
set(PACKAGE_BUGREPORT "[email protected]")
set(PACKAGE_NAME "libsmb2")
set(PACKAGE_VERSION "${VERSION}")
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set(PACKAGE_TARNAME "${PACKAGE}")
set(PACKAGE_URL "https://github.com/sahlberg/libsmb2")
endif()
configure_file(libsmb2.pc.in libsmb2.pc @ONLY)
endif()
if(NOT PICO_BOARD OR NOT ESP_PLATFORM)
set(SOVERSION 1 CACHE STRING "" FORCE)
if(NOT IOP AND NOT BUILD_IRX)
set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE PATH "Installation directory for libraries")
set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers")
set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files")
set(INSTALL_CMAKE_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/cmake/libsmb2" CACHE PATH "Installation directory for cmake (.cmake) files")
endif()
if(CMAKE_SYSTEM_NAME MATCHES NintendoSwitch OR CMAKE_SYSTEM_NAME MATCHES Nintendo3DS OR PS4 OR PS2 OR VITA OR CMAKE_SYSTEM_NAME MATCHES Dreamcast OR CMAKE_SYSTEM_NAME MATCHES NintendoGameCube OR CMAKE_SYSTEM_NAME MATCHES NintendoDS OR CMAKE_SYSTEM_NAME MATCHES NintendoWii OR CMAKE_SYSTEM_NAME MATCHES CafeOS)
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
else()
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
endif()
option(ENABLE_EXAMPLES "Build example programs" OFF)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
endif()
if(CMAKE_SYSTEM_NAME MATCHES Linux)
find_package(LibKrb5)
elseif(IOS)
find_package(GSSAPI)
endif()
if(NOT PICO_BOARD OR NOT ESP_PLATFORM)
include(cmake/ConfigureChecks.cmake)
endif()
if(PICO_BOARD)
include_directories(libsmb2 STATIC
${PICO_SDK_PATH}/lib/lwip/src/include
${PICO_SDK_PATH}/src/rp2_common/pico_lwip/include
lib
include
include/smb2
include/picow
)
elseif(ESP_PLATFORM)
set(COMPONENT_ADD_INCLUDEDIRS
"lib"
include
include/smb2
include/esp
)
else()
include_directories(${CMAKE_CURRENT_BINARY_DIR}
include
include/smb2
)
endif()
if(CMAKE_SYSTEM_NAME MATCHES Linux)
set(core_DEPENDS ${LIBKRB5_LIBRARY} CACHE STRING "" FORCE)
elseif(IOS)
set(core_DEPENDS ${GSSAPI_LIBRARIES} CACHE STRING "" FORCE)
endif()
if(MSVC AND BUILD_SHARED_LIBS)
# If we are building dll with msvc, then generate a def file according to the syms file
set(SYMS_FILE_PATH "${PROJECT_SOURCE_DIR}/lib/libsmb2.syms")
set(DEF_FILE_PATH "${PROJECT_BINARY_DIR}/lib/libsmb2.def")
file(READ ${SYMS_FILE_PATH} EXPORT_SYMBOLS)
file(WRITE ${DEF_FILE_PATH} "LIBRARY smb2\nEXPORTS\n\n${EXPORT_SYMBOLS}")
# Pass def file to the linker
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DEF:${DEF_FILE_PATH}")
endif()
if(CMAKE_SYSTEM_NAME MATCHES Windows)
list(APPEND CORE_LIBRARIES ws2_32.lib)
add_definitions(-DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_WARNINGS -DHAVE_LINGER -DNEED_GETLOGIN_R -DNEED_GETPID -DNEED_RANDOM -DNEED_SRANDOM)
elseif(CMAKE_SYSTEM_NAME MATCHES NintendoSwitch)
add_definitions(-DARM11 -DSWITCH -D__SWITCH__ -DNEED_READV -DNEED_WRITEV -DNEED_GETLOGIN_R)
set(ARCH "-march=armv8-a -mtp=soft -fPIE")
set(CMAKE_C_FLAGS "-g -Wall -O2 -ffast-math ${ARCH}")
set(CMAKE_C_FLAGS "-Wno-unused-variable")
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -fno-rtti -std=gnu++11")
set(CMAKE_C_LDFLAGS "${CMAKE_C_FLAGS} -specs=switch.specs -g ${ARCH} -Wl,-Map,$(notdir $*.map)")
add_compile_options("${CMAKE_C_FLAGS} ${CMAKE_LDFLAGS}")
elseif(CMAKE_SYSTEM_NAME MATCHES Nintendo3DS)
add_definitions(-DARM11 -D_3DS -D__3DS__ -DNEED_READV -DNEED_WRITEV -DNEED_GETLOGIN_R)
set(ARCH "-march=armv6k -mfloat-abi=hard -mtune=mpcore -mtp=soft -fPIE")
set(CMAKE_C_FLAGS "-Wno-unused-variable -g -Wall -O2 -mword-relocations -fomit-frame-pointer -ffast-math ${ARCH}")
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -fno-rtti -fno-exceptions -std=gnu++11")
set(CMAKE_C_LDFLAGS "${CMAKE_C_FLAGS} -specs=3dsx.specs -g ${ARCH} -Wl,-Map,$(notdir $*.map)")
add_compile_options("${CMAKE_C_FLAGS} ${CMAKE_LDFLAGS}")
elseif(CMAKE_SYSTEM_NAME MATCHES NintendoDS)
add_definitions(-DARM9 -D__NDS__ -DNEED_READV -DNEED_WRITEV -DNEED_GETLOGIN_R -DNEED_GETADDRINFO -DNEED_FREEADDRINFO -DNEED_POLL)
set(CMAKE_C_FLAGS "-Wno-format -Wpointer-arith")
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -fno-rtti -fno-exceptions -std=gnu++11")
set(CMAKE_C_LDFLAGS "${CMAKE_C_FLAGS} -specs=ds_arm9.specs -g")
add_compile_options("${CMAKE_C_FLAGS} ${CMAKE_LDFLAGS}")
elseif(CMAKE_SYSTEM_NAME MATCHES NintendoGameCube)
add_definitions(-DGEKKO -D__GC__ -DNEED_READV -DNEED_WRITEV -DNEED_GETLOGIN_R -DNEED_GETADDRINFO -DNEED_FREEADDRINFO -DNEED_POLL)
set(CMAKE_C_FLAGS "-g")
#-O3 -Wall
add_compile_options("${CMAKE_C_FLAGS}")
elseif(CMAKE_SYSTEM_NAME MATCHES NintendoWii)
add_definitions(-DGEKKO -D__WII__ -DNEED_READV -DNEED_WRITEV -DNEED_GETLOGIN_R -DNEED_GETADDRINFO -DNEED_FREEADDRINFO -DNEED_POLL)
set(CMAKE_C_FLAGS "-g")
#-O3 -Wall
add_compile_options("${CMAKE_C_FLAGS}")
elseif(CMAKE_SYSTEM_NAME MATCHES CafeOS)
add_definitions(-D__WIIU__ -DNEED_READV -DNEED_WRITEV -DNEED_GETLOGIN_R)
set(CMAKE_C_FLAGS "-g")
#-O3 -Wall
add_compile_options("${CMAKE_C_FLAGS}")
elseif(PS4)
add_definitions(-DPS4_PLATFORM)
set(CMAKE_C_FLAGS "-funwind-tables")
#-fuse-init-array -emit-llvm broken...
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}")
add_compile_options("${CMAKE_C_FLAGS}")
elseif(EE)
add_definitions(-DNEED_BE64TOH -DNEED_POLL -DNEED_WRITEV -DNEED_READV -DNEED_GETLOGIN_R)
if(EE AND PS2RPC)
add_definitions(-DPS2RPC)
endif()
elseif(IOP)
add_definitions(-DHAVE_CONFIG_H -DNEED_BE64TOH -DNEED_STRDUP -DNEED_READV -DNEED_WRITEV -DNEED_POLL -DNEED_GETPID -DNEED_RANDOM -DNEED_SRANDOM -DNEED_GETLOGIN_R -DHAVE_STRING_H -DHAVE_SYS_FCNTL_H)
if(IOP AND BUILD_IRX)
add_definitions(-D__ps2sdk_iop__)
if(DEBUG)
add_definitions(-DDEBUG)
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fno-builtin")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s")
endif()
set(CMAKE_C_FLAGS "-Wall")
include_directories(${CMAKE_CURRENT_BINARY_DIR} include/ps2)
add_compile_options("${CMAKE_C_FLAGS}")
elseif(VITA)
add_definitions(-DNEED_READV -DNEED_WRITEV -DNEED_GETLOGIN_R)
elseif(PICO_BOARD)
add_definitions(-DNEED_BE64TOH -DNEED_POLL -DNEED_GETLOGIN_R)
elseif(ESP_PLATFORM)
if(NOT CMAKE_BUILD_EARLY_EXPANSION)
add_definitions(-DHAVE_CONFIG_H)
endif()
add_definitions(-DNEED_READV -DNEED_WRITEV -DNEED_GETLOGIN_R -DNEED_RANDOM -DNEED_SRANDOM)
elseif(CMAKE_SYSTEM_NAME MATCHES Dreamcast)
add_definitions(-DNEED_WRITEV -DNEED_READV -DHAVE_CONFIG_H -DNEED_GETLOGIN_R)
elseif(CMAKE_SYSTEM_NAME STREQUAL Solaris)
find_library(SOCKET_LIBRARY socket)
find_library(NSL_LIBRARY nsl)
list(APPEND CORE_LIBRARIES ${SOCKET_LIBRARY} ${NSL_LIBRARY})
endif()
if(ENABLE_EXAMPLES)
add_subdirectory(examples)
endif()
add_subdirectory(lib)
if(NOT PICO_BOARD OR ESP_PLATFORM)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/libsmb2-config-version.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion)
if(NOT IOP AND NOT BUILD_IRX)
configure_file(cmake/libsmb2.pc.cmake
${CMAKE_CURRENT_BINARY_DIR}/libsmb2.pc @ONLY)
install(DIRECTORY include/smb2
DESTINATION ${INSTALL_INC_DIR})
install(FILES cmake/FindSMB2.cmake
${CMAKE_CURRENT_BINARY_DIR}/libsmb2-config-version.cmake
DESTINATION ${INSTALL_CMAKE_DIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libsmb2.pc
DESTINATION ${INSTALL_PKGCONFIG_DIR})
endif()
endif()