]> FriiDump Source - friidump.git/blob - CMakeLists.txt
Fix MSVC CMake SHA1 header resolution
[friidump.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8)
2
3 # The name of our project is "HELLO".  CMakeLists files in this project can
4 # refer to the root source directory of the project as ${HELLO_SOURCE_DIR} and
5 # to the root binary directory of the project as ${HELLO_BINARY_DIR}.
6 project (FriiDump)
7
8 if (UNIX AND NOT WIN32)
9     message (WARNING
10         "Linux vendor-command paths require CAP_SYS_RAWIO. "
11         "A normal build does not install this capability. "
12         "After validating the exact executable, run "
13         "validation/friidump-linux-rawio-capability.sh install. "
14         "Do not run the entire FriiDump process as root; rebuilding or replacing "
15         "the executable clears file capabilities."
16     )
17 endif ()
18
19 if (MSVC)
20     # msvc2005 deprecated warnings
21     add_definitions (-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
22 else (MSVC)
23     if (NOT WIN32)
24       add_definitions (-fPIC)
25     endif (NOT WIN32)
26 endif (MSVC)
27
28
29 include (TestBigEndian)
30
31 test_big_endian (CMAKE_WORDS_BIGENDIAN)
32
33
34 include (CheckIncludeFiles)
35
36 check_include_files (stdbool.h HAVE_STDBOOL_H)
37
38
39 include (CheckFunctionExists)
40
41 check_function_exists (fseeko HAVE_FSEEKO)
42 check_function_exists (ftello HAVE_FTELLO)
43 check_function_exists (fseek64 HAVE_FSEEK64)
44 check_function_exists (ftell64 HAVE_FTELL64)
45
46
47 include(CheckTypeSize)
48
49 set (CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64)
50
51 set (CMAKE_EXTRA_INCLUDE_FILES sys/types.h)
52 check_type_size ("off_t" OFF_T)
53 set (CMAKE_EXTRA_INCLUDE_FILES)
54
55 set (CMAKE_EXTRA_INCLUDE_FILES stdio.h)
56 check_type_size ("fpos_t" FPOS_T)
57 set (CMAKE_EXTRA_INCLUDE_FILES)
58
59 set (CMAKE_REQUIRED_DEFINITIONS)
60
61
62 option (
63         DEBUG
64         "Enable debugging messages"
65         OFF
66 )
67
68
69 option (
70         BUILD_STATIC_BINARY
71         "Build a static binary (has precedence over ALL_LIBS_SHARED)"
72         OFF
73 )
74
75 option (
76         BUILD_ALL_LIBS_SHARED
77         "Build all libraries as shared"
78         OFF
79 )
80
81 option (
82         BUILD_NATIVE_REPORT_TESTS
83         "Build the native-report fixture generator"
84         OFF
85 )
86
87 option (
88         BUILD_HLDS_PROFILE_TESTS
89         "Build the read-only HLDS E7 profile-selection tests"
90         OFF
91 )
92
93 set (
94         FRIIDUMP_BUILD_COMMIT
95         ""
96         CACHE STRING
97         "Full 40-character Git commit embedded in native compatibility reports"
98 )
99
100 if (FRIIDUMP_BUILD_COMMIT)
101         string (LENGTH "${FRIIDUMP_BUILD_COMMIT}" FRIIDUMP_BUILD_COMMIT_LENGTH)
102         if (NOT FRIIDUMP_BUILD_COMMIT_LENGTH EQUAL 40 OR FRIIDUMP_BUILD_COMMIT MATCHES "[^0-9A-Fa-f]")
103                 message (FATAL_ERROR "FRIIDUMP_BUILD_COMMIT must be exactly 40 hexadecimal characters")
104         endif ()
105 endif ()
106
107 if (BUILD_STATIC_BINARY)
108         set (libmultihash_type STATIC)
109         set (libfriidump_type STATIC)
110 elseif (BUILD_ALL_LIBS_SHARED)
111         set (libmultihash_type SHARED)
112         set (libfriidump_type SHARED)
113 else (BUILD_STATIC_BINARY)
114         # This is how we build libraries by default
115         set (libmultihash_type STATIC)
116         set (libfriidump_type SHARED)
117 endif (BUILD_STATIC_BINARY)
118
119
120 # set (CMAKE_BUILD_TYPE superoptimized)
121 set (CMAKE_C_FLAGS_SUPEROPTIMIZED "-march=athlon-xp -m3dnow -O3 -funroll-all-loops")
122
123 set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall")
124
125 # set (CMAKE_BUILD_TYPE release)
126
127 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
128 add_definitions(-DHAVE_CONFIG_H)
129 include_directories (
130         ${FriiDump_BINARY_DIR}
131 )
132
133 # Recurse into the "Hello" and "Demo" subdirectories.  This does not actually
134 # cause another cmake executable to run.  The same process will walk through
135 # the project's entire directory structure.
136 add_subdirectory (libmultihash)
137 add_subdirectory (libfriidump)
138 add_subdirectory (src)
139
140 if (BUILD_HLDS_PROFILE_TESTS)
141         enable_testing ()
142         include_directories (
143                 ${FriiDump_SOURCE_DIR}/libfriidump
144         )
145         add_executable (
146                 test_hlds_e7_profiles
147                 tests/test_hlds_e7_profiles.c
148         )
149         target_link_libraries (
150                 test_hlds_e7_profiles
151                 friidumplib
152         )
153         add_test (
154                 NAME hlds_e7_profiles
155                 COMMAND test_hlds_e7_profiles
156         )
157 endif (BUILD_HLDS_PROFILE_TESTS)
158
159
160 if (WIN32)
161         install (FILES AUTHORS DESTINATION / RENAME Authors.txt)
162         #install (CODE "exec_program (${CMAKE_CURRENT_SOURCE_DIR}/utils/unix2dos.exe ${CMAKE_OUTPUT_BINARY_DIR} ARGS Authors.txt)")
163         install (FILES ChangeLog DESTINATION / RENAME ChangeLog.txt)
164         install (FILES COPYING DESTINATION / RENAME Copying.txt)
165         install (FILES README DESTINATION / RENAME ReadMe.txt)
166         install (FILES TODO DESTINATION / RENAME ToDo.txt)
167 endif (WIN32)
168
169
170 # CPack stuff
171 include (InstallRequiredSystemLibraries)
172
173 set (CPACK_PACKAGE_NAME "friidump")
174 set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Dump Nintendo GameCube/Wii discs")
175 set (CPACK_PACKAGE_VENDOR "Arep")
176 set (CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
177 set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
178 set (CPACK_PACKAGE_VERSION_MAJOR "0")
179 set (CPACK_PACKAGE_VERSION_MINOR "3")
180 set (CPACK_PACKAGE_VERSION_PATCH "0")
181 set (CPACK_PACKAGE_INSTALL_DIRECTORY "FriiDump ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
182 set (CPACK_PACKAGE_EXECUTABLES "friidump" "FriiDump")
183
184 set (CPACK_SOURCE_GENERATOR "TBZ2;ZIP")
185 set (CPACK_SOURCE_IGNORE_FILES
186         "/CVS/"
187         "/\\\\.svn/"
188         "~$"
189         "tags"
190         "\\\\.kdevses$"
191         "\\\\.kdevelop\\\\.pcs$"
192         "/BUILD.*/"
193         "/RELEASES/"
194         "/utils/"
195         "/doc.*/"
196 )
197 set (CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
198
199 if(WIN32 AND NOT UNIX)
200         set (CPACK_GENERATOR "NSIS;ZIP")
201         # There is a bug in NSI that does not handle full unix paths properly. Make
202         # sure there is at least one set of four (4) backlasshes.
203 #       set (CPACK_PACKAGE_ICON "${CMake_SOURCE_DIR}/Utilities/Release\\\\InstallIcon.bmp")
204 #       set (CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\MyExecutable.exe")
205         set (CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} installer")
206         set (CPACK_NSIS_HELP_LINK "http:\\\\\\\\wii.console-tribe.com")
207         set (CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.my-personal-home-page.com")
208         set (CPACK_NSIS_CONTACT "arep@no.net")
209         set (CPACK_NSIS_MODIFY_PATH ON)
210
211         set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}-Win32")
212 else(WIN32 AND NOT UNIX)
213         set (CPACK_GENERATOR "TBZ2")
214         set (CPACK_STRIP_FILES "bin/friidump;lib/libfriidump.so.1.0.0")
215 #   set (CPACK_SOURCE_STRIP_FILES "")
216         set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}-LinuxBin")
217 endif(WIN32 AND NOT UNIX)
218
219 include (CPack)