[libzomg] Metadata_win32.cpp::getUserName_ansi(): Only check for NULLs if cbUsername...
[~korth/gens-gs-ii.git] / CMakeLists.txt
1 PROJECT(gens-gs-ii)
2
3 # Version dependencies:
4 # - BREAK(): CMake 2.6.0
5 # - NASM: CMake 2.8.4
6 CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0)
7
8 # Set default build options.
9 INCLUDE(cmake/options.cmake)
10
11 list (APPEND CMAKE_MODULE_PATH
12 "${gens-gs-ii_SOURCE_DIR}/cmake/macros"
13 "${gens-gs-ii_SOURCE_DIR}/cmake/libs"
14 )
15
16 # Mac OS X: CMake doesn't include this by default.
17 INCLUDE(CheckLibraryExists)
18
19 # Split Debug macro.
20 # Also sets the image version for Windows builds.
21 INCLUDE(Win32ImageVersionLinkerFlags)
22 MACRO(DO_SPLIT_DEBUG _TARGET)
23 # Split debug information.
24 INCLUDE(SetMSVCDebugPath)
25 SET_MSVC_DEBUG_PATH(${_TARGET})
26 IF(SPLIT_DEBUG)
27 INCLUDE(SplitDebugInformation)
28 SPLIT_DEBUG_INFORMATION(${_TARGET})
29 ENDIF(SPLIT_DEBUG)
30 # Set image version.
31 # Subprojects can override ${VERSION_MAJOR} and ${VERSION_MINOR}.
32 # FIXME: If minor version is e.g. "3", Windows interprets it as "03",
33 # so "1.3" will actually be "1.03".
34 WIN32_IMAGE_VERSION_LINKER_FLAGS(${VERSION_MAJOR} ${VERSION_MINOR})
35 ENDMACRO(DO_SPLIT_DEBUG)
36
37 # Testing functions.
38 INCLUDE(cmake/gtest.cmake)
39
40 # Program information.
41 SET(DESCRIPTION "Gens/GS II")
42 SET(AUTHOR "David Korth")
43 SET(VERSION_MAJOR 0)
44 SET(VERSION_MINOR 0)
45 SET(VERSION_PATCH 0)
46 SET(VERSION_DEVEL 1)
47 IF(VERSION_PATCH)
48 SET(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
49 ELSE(VERSION_PATCH)
50 SET(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}")
51 ENDIF(VERSION_PATCH)
52 IF(VERSION_DEVEL)
53 SET(VERSION_STRING "${VERSION_STRING}+")
54 ENDIF(VERSION_DEVEL)
55 SET(VERSION_STRING_WIN32 "${VERSION_MAJOR},${VERSION_MINOR},${VERSION_PATCH},${VERSION_DEVEL}")
56
57 # Git version information.
58 FIND_PROGRAM(POSIX_SH sh)
59 IF(POSIX_SH)
60 # sh is available.
61 # Run the git version script.
62 IF(WIN32)
63 SET(ENV{SHELLOPTS} igncr)
64 ENDIF(WIN32)
65 ADD_CUSTOM_TARGET(git_version ALL
66 ${POSIX_SH} ${gens-gs-ii_SOURCE_DIR}/git_version.sh
67 -s "${gens-gs-ii_SOURCE_DIR}"
68 -o "${gens-gs-ii_BINARY_DIR}/git_version.h"
69 VERBATIM
70 )
71 ELSE(POSIX_SH)
72 # sh isn't available.
73 # Create a blank git_version.h.
74 FILE(WRITE "${gens-gs-ii_BINARY_DIR}/git_version.h"
75 "/* dummy file; POSIX sh is not available */\n")
76 ENDIF(POSIX_SH)
77
78 # If no build type is set, default to "debug".
79 IF(CMAKE_BUILD_TYPE MATCHES ^$)
80 SET(CMAKE_BUILD_TYPE "debug")
81 ENDIF()
82
83 # Don't bother with verbose makefiles for now.
84 # TODO: Make it an option?
85 #IF (CMAKE_BUILD_TYPE MATCHES ^debug$)
86 #SET(CMAKE_VERBOSE_MAKEFILE ON)
87 #ENDIF()
88
89 # Check for platform-specific functionality.
90 INCLUDE(cmake/platform.cmake)
91
92 IF(CMAKE_CROSSCOMPILING)
93 # Cross-compiling requires a native build due to generated
94 # executables being used in the build process.
95 # Reference: http://www.cmake.org/Wiki/CMake_Cross_Compiling
96 SET(IMPORT_EXECUTABLES "IMPORTFILE-NOTFOUND"
97 CACHE PATH "Point this to the root directory of a native build.")
98 IF(NOT IMPORT_EXECUTABLES)
99 MESSAGE(FATAL_ERROR "IMPORT_EXECUTABLES is not set.\nPoint it to the root directory of a native build.")
100 ENDIF(NOT IMPORT_EXECUTABLES)
101 IF(NOT EXISTS "${IMPORT_EXECUTABLES}/")
102 MESSAGE(FATAL_ERROR "IMPORT_EXECUTABLES is not set to a valid directory.\nPoint it to the root directory of a native build.")
103 ENDIF(NOT EXISTS "${IMPORT_EXECUTABLES}/")
104 ENDIF(CMAKE_CROSSCOMPILING)
105
106 # Check for required libraries.
107 INCLUDE(CheckZLIB)
108 INCLUDE(CheckPNG)
109 INCLUDE(CheckLZMA)
110 INCLUDE(CheckOpenGL)
111 INCLUDE(CheckPopt)
112
113 # Project subdirectories.
114 ADD_SUBDIRECTORY(extlib)
115 ADD_SUBDIRECTORY(src)
116
117 # Documentation.
118 IF(BUILD_DOC)
119 ADD_SUBDIRECTORY(doc)
120 ENDIF(BUILD_DOC)