]> FriiDump Source - friidump.git/blob - CMakeLists.txt
635300d426df2f5273a161cac6d41f0c6ebc1a54
[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 the candidate validation "
13         "script's capability phase or 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 set (
88         FRIIDUMP_BUILD_COMMIT
89         ""
90         CACHE STRING
91         "Full 40-character Git commit embedded in native compatibility reports"
92 )
93
94 if (FRIIDUMP_BUILD_COMMIT)
95         string (LENGTH "${FRIIDUMP_BUILD_COMMIT}" FRIIDUMP_BUILD_COMMIT_LENGTH)
96         if (NOT FRIIDUMP_BUILD_COMMIT_LENGTH EQUAL 40 OR FRIIDUMP_BUILD_COMMIT MATCHES "[^0-9A-Fa-f]")
97                 message (FATAL_ERROR "FRIIDUMP_BUILD_COMMIT must be exactly 40 hexadecimal characters")
98         endif ()
99 endif ()
100
101 if (BUILD_STATIC_BINARY)
102         set (libmultihash_type STATIC)
103         set (libfriidump_type STATIC)
104 elseif (BUILD_ALL_LIBS_SHARED)
105         set (libmultihash_type SHARED)
106         set (libfriidump_type SHARED)
107 else (BUILD_STATIC_BINARY)
108         # This is how we build libraries by default
109         set (libmultihash_type STATIC)
110         set (libfriidump_type SHARED)
111 endif (BUILD_STATIC_BINARY)
112
113
114 # set (CMAKE_BUILD_TYPE superoptimized)
115 set (CMAKE_C_FLAGS_SUPEROPTIMIZED "-march=athlon-xp -m3dnow -O3 -funroll-all-loops")
116
117 set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall")
118
119 # set (CMAKE_BUILD_TYPE release)
120
121 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
122 add_definitions(-DHAVE_CONFIG_H)
123 include_directories (
124         ${FriiDump_BINARY_DIR}
125 )
126
127 # Recurse into the "Hello" and "Demo" subdirectories.  This does not actually
128 # cause another cmake executable to run.  The same process will walk through
129 # the project's entire directory structure.
130 add_subdirectory (libmultihash)
131 add_subdirectory (libfriidump)
132 add_subdirectory (src)
133
134
135 if (WIN32)
136         install (FILES AUTHORS DESTINATION / RENAME Authors.txt)
137         #install (CODE "exec_program (${CMAKE_CURRENT_SOURCE_DIR}/utils/unix2dos.exe ${CMAKE_OUTPUT_BINARY_DIR} ARGS Authors.txt)")
138         install (FILES ChangeLog DESTINATION / RENAME ChangeLog.txt)
139         install (FILES COPYING DESTINATION / RENAME Copying.txt)
140         install (FILES README DESTINATION / RENAME ReadMe.txt)
141         install (FILES TODO DESTINATION / RENAME ToDo.txt)
142 endif (WIN32)
143
144
145 # CPack stuff
146 include (InstallRequiredSystemLibraries)
147
148 set (CPACK_PACKAGE_NAME "friidump")
149 set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Dump Nintendo GameCube/Wii discs")
150 set (CPACK_PACKAGE_VENDOR "Arep")
151 set (CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
152 set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
153 set (CPACK_PACKAGE_VERSION_MAJOR "0")
154 set (CPACK_PACKAGE_VERSION_MINOR "3")
155 set (CPACK_PACKAGE_VERSION_PATCH "0")
156 set (CPACK_PACKAGE_INSTALL_DIRECTORY "FriiDump ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
157 set (CPACK_PACKAGE_EXECUTABLES "friidump" "FriiDump")
158
159 set (CPACK_SOURCE_GENERATOR "TBZ2;ZIP")
160 set (CPACK_SOURCE_IGNORE_FILES
161         "/CVS/"
162         "/\\\\.svn/"
163         "~$"
164         "tags"
165         "\\\\.kdevses$"
166         "\\\\.kdevelop\\\\.pcs$"
167         "/BUILD.*/"
168         "/RELEASES/"
169         "/utils/"
170         "/doc.*/"
171 )
172 set (CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
173
174 if(WIN32 AND NOT UNIX)
175         set (CPACK_GENERATOR "NSIS;ZIP")
176         # There is a bug in NSI that does not handle full unix paths properly. Make
177         # sure there is at least one set of four (4) backlasshes.
178 #       set (CPACK_PACKAGE_ICON "${CMake_SOURCE_DIR}/Utilities/Release\\\\InstallIcon.bmp")
179 #       set (CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\MyExecutable.exe")
180         set (CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} installer")
181         set (CPACK_NSIS_HELP_LINK "http:\\\\\\\\wii.console-tribe.com")
182         set (CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.my-personal-home-page.com")
183         set (CPACK_NSIS_CONTACT "arep@no.net")
184         set (CPACK_NSIS_MODIFY_PATH ON)
185
186         set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}-Win32")
187 else(WIN32 AND NOT UNIX)
188         set (CPACK_GENERATOR "TBZ2")
189         set (CPACK_STRIP_FILES "bin/friidump;lib/libfriidump.so.1.0.0")
190 #   set (CPACK_SOURCE_STRIP_FILES "")
191         set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}-LinuxBin")
192 endif(WIN32 AND NOT UNIX)
193
194 include (CPack)