Basic configure functionality for cmake
authorChristoph Sommer <mail@christoph-sommer.de>
Fri, 12 Jan 2007 17:57:06 +0000 (17:57 +0000)
committerChristoph Sommer <mail@christoph-sommer.de>
Fri, 12 Jan 2007 17:57:06 +0000 (17:57 +0000)
SVN-Revision: 4552

CMakeLists.txt
config.h.cmake [new file with mode: 0644]
mk/cmake/ConfigureChecks.cmake [new file with mode: 0644]

index 200a517..ab32f9b 100644 (file)
 
 PROJECT(SUPERTUX)
 
+## Some default settings
+
+set(DEBUG 0 CACHE BOOL "Build with debugging options")
+set(ENABLE_BINRELOC 0 CACHE BOOL "Enable autopackage's BINRELOC features")
+set(APPDATADIR "" CACHE STRING "APPDATADIR for autopackage's BINRELOC features")
+set(ENABLE_SQDBG 0 CACHE BOOL "Build squirrel script interpreter with debugging options")
+
 ## Search here for additional cmake modules (for finding deps)
 
 set(CMAKE_MODULE_PATH ${SUPERTUX_SOURCE_DIR}/mk/cmake ${CMAKE_MODULE_PATH})
@@ -79,6 +86,19 @@ FIND_PACKAGE(PhysFS REQUIRED)
 INCLUDE_DIRECTORIES(${PHYSFS_INCLUDE_DIR})
 LINK_LIBRARIES(${PHYSFS_LIBRARY})
 
+#FIND_PACKAGE(ICONV REQUIRED)
+#INCLUDE_DIRECTORIES(${ICONV_INCLUDE_DIR})
+#LINK_LIBRARIES(${ICONV_LIBRARY})
+
+## Check platform-dependent build options
+
+INCLUDE(ConfigureChecks)
+
+## Create config.h
+
+configure_file(config.h.cmake ${CMAKE_BINARY_DIR}/config.h )
+include_directories (${CMAKE_BINARY_DIR}/)
+
 ## Also execute instructions in src/squirrel/CMakeLists.txt
 
 ADD_SUBDIRECTORY(src/squirrel)
@@ -89,7 +109,6 @@ LINK_DIRECTORIES(src/squirrel)
 
 ## Some additional include paths
 
-include_directories (${SUPERTUX_SOURCE_DIR}/)
 include_directories (${SUPERTUX_SOURCE_DIR}/src/)
 include_directories (${SUPERTUX_SOURCE_DIR}/src/squirrel/include/)
 
diff --git a/config.h.cmake b/config.h.cmake
new file mode 100644 (file)
index 0000000..3838a39
--- /dev/null
@@ -0,0 +1,23 @@
+#define PACKAGE_NAME "supertux"
+#define PACKAGE_VERSION "0.3.0"
+
+#cmakedefine DEBUG
+#cmakedefine ENABLE_SQDBG
+
+#cmakedefine ENABLE_BINRELOC
+#ifdef ENABLE_BINRELOC
+#define APPDATADIR ${APPDATADIR}
+#endif
+
+#define SIZEOF_VOID_P ${SIZEOF_VOID_P}
+#if SIZEOF_VOID_P == 8
+#define _SQ64
+#endif
+
+#cmakedefine HAVE_ICONV_CONST
+#ifdef HAVE_ICONV_CONST
+#define ICONV_CONST const
+#else
+#define ICONV_CONST
+#endif
+
diff --git a/mk/cmake/ConfigureChecks.cmake b/mk/cmake/ConfigureChecks.cmake
new file mode 100644 (file)
index 0000000..90fcfd2
--- /dev/null
@@ -0,0 +1,16 @@
+include(CheckCXXSourceCompiles)
+include(CheckTypeSize)
+
+check_cxx_source_compiles(
+       "
+       #include <iconv.h>
+       // this declaration will fail when there already exists a non const char** version which returns size_t
+       double iconv(iconv_t cd,  char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft);
+       int main() { return 0; }
+       "
+       HAVE_ICONV_CONST
+)
+
+CHECK_TYPE_SIZE("void*" SIZEOF_VOID_P)
+message(STATUS "Size of void* is ${SIZEOF_VOID_P}")
+