initial import
authorhrnt
Sat, 25 Oct 2008 09:07:17 +0000
changeset 0 c8174cf25e06
child 1 085631252347
initial import
CMakeLists.txt
data/CMakeLists.txt
src/CMakeLists.txt
src/config.h.in
src/main.cc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CMakeLists.txt	Sat Oct 25 09:07:17 2008 +0000
@@ -0,0 +1,28 @@
+set(PROJECT_SHORT_NAME "exampleproject")
+set(PROJECT_LONG_NAME "Example Project")
+set(PROJECT_VERSION_MAJOR 0)
+set(PROJECT_VERSION_MINOR 1)
+
+project(${PROJECT_SHORT_NAME})
+cmake_minimum_required(VERSION 2.6)
+
+# Avoid source tree pollution
+if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
+	message(FATAL_ERROR "In-source builds are not permitted. Make a separate folder for building:\nmkdir build; cd build; cmake ..\nBefore that, remove the files already created:\nrm -rf CMakeCache.txt CMakeFiles")
+endif(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
+
+# Where to install project data files
+set(PROJECT_DATA_DIR "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_SHORT_NAME}")
+
+# Where to look for Find*.cmake and other modules
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
+
+# Add a sensible build type default and warning because empty means no optimization and no debug info.
+if(NOT CMAKE_BUILD_TYPE)
+	message("WARNING: CMAKE_BUILD_TYPE is not defined!\n         Defaulting to CMAKE_BUILD_TYPE=Release. Use ccmake to set a proper value.")
+	set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
+endif(NOT CMAKE_BUILD_TYPE)
+
+add_subdirectory(src)
+add_subdirectory(data)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data/CMakeLists.txt	Sat Oct 25 09:07:17 2008 +0000
@@ -0,0 +1,7 @@
+# Match all files, except hidden ones (which begin with dot).
+file(GLOB DATA_FILES "share/[^.]*")
+
+if(DATA_FILES)
+	install(FILES ${DATA_FILES} DESTINATION "${PROJECT_DATA_DIR}")
+endif(DATA_FILES)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/CMakeLists.txt	Sat Oct 25 09:07:17 2008 +0000
@@ -0,0 +1,29 @@
+FILE(GLOB SOURCE_FILES "*.cc")
+FILE(GLOB HEADER_FILES "*.hh")
+
+set(SOURCES ${SOURCE_FILES} ${HEADER_FILES})
+
+# Set default compile flags for GCC
+if(CMAKE_COMPILER_IS_GNUCXX)
+	message(STATUS "GCC detected, enabling pedantic mode and warnings")
+	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98 -pedantic -Wall -Wextra")
+endif(CMAKE_COMPILER_IS_GNUCXX)
+
+# Generate config.h
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/config.h" @ONLY)
+include_directories("${CMAKE_CURRENT_BINARY_DIR}")
+
+# Libraries
+
+# An example of how to use a library. You'll need FindExampleLibrary.cmake for this to work
+# Put that file in trunk/cmake/Modules/ and also look inside the file for further instructions.
+#find_package(ExampleLibrary REQUIRED)
+#include_directories(${ExampleLibrary_INCLUDE_DIRS})
+#set(LIBS ${LIBS} ${ExampleLibrary_LIBRARIES})
+
+# Assumes the project generates only one executable. If you need more, you'll need to alter
+# the script and replace ${PROJECT_SHORT_NAME} by executable name.
+add_executable("${PROJECT_SHORT_NAME}" ${SOURCES})
+target_link_libraries("${PROJECT_SHORT_NAME}" ${LIBS})
+install(TARGETS "${PROJECT_SHORT_NAME}" DESTINATION bin)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/config.h.in	Sat Oct 25 09:07:17 2008 +0000
@@ -0,0 +1,13 @@
+#ifndef @PROJECT_SHORT_NAME@_CONFIG_H
+#define @PROJECT_SHORT_NAME@_CONFIG_H
+
+/* Note: CMake autogenerates build/src/config.h from src/config.h.in */
+/* #include "config.h" to use the generated file */
+
+#define PROJECT_DATA_DIR "@PROJECT_DATA_DIR@"
+#define PROJECT_SHORT_NAME "@PROJECT_SHORT_NAME@"
+#define PROJECT_LONG_NAME "@PROJECT_LONG_NAME@"
+#define PROJECT_VERSION "@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@"
+
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main.cc	Sat Oct 25 09:07:17 2008 +0000
@@ -0,0 +1,7 @@
+#include "config.h"
+#include <iostream>
+
+int main() {
+	std::cout << "Hello from " PROJECT_LONG_NAME " " PROJECT_VERSION << std::endl;
+}
+