ref: 9e2c91079ddbbc3d968f17e78b734d529af2afcd
parent: 07c545a6b7437f30c2864892a1709efcb50b521b
parent: 98e7d70de745097165e1ea40ded2d3d7e16699b4
author: Chris Moeller <kode54@gmail.com>
date: Fri Apr 4 15:46:41 EDT 2014
Merge pull request #4 from katajakasa/ttv-cmake-improvements CMake readme+improvements
--- a/dumb/cmake/CMakeLists.txt
+++ b/dumb/cmake/CMakeLists.txt
@@ -1,13 +1,12 @@
cmake_minimum_required(VERSION 2.6)
project(libdumb C)
-OPTION(BUILD_SHARED "Build Shared Library (OFF for Static)" ON)
+set(CMAKE_C_FLAGS "-Wall -DDUMB_DECLARE_DEPRECATED -D_USE_SSE -msse -Wno-unused-variable -Wno-unused-but-set-variable")
+set(CMAKE_C_FLAGS_DEBUG "-ggdb -DDEBUGMODE=1 -D_DEBUG")
+set(CMAKE_C_FLAGS_RELEASE "-ffast-math -O2 -DNDEBUG")
+set(CMAKE_C_FLAGS_RELWITHDEBINFO "-ffast-math -g -O2 -DNDEBUG")
+set(CMAKE_C_FLAGS_MINSIZEREL "-ffast-math -Os -DNDEBUG")
-set(COMMON_FLAGS "-Wall -DDUMB_DECLARE_DEPRECATED -D_USE_SSE -Wno-unused-but-set-variable")
-set(CMAKE_C_FLAGS "${COMMON_FLAGS} -ffast-math -O2")
-set(CMAKE_C_FLAGS_DEBUG "${COMMON_FLAGS} -ggdb -DDEBUGMODE")
-set(CMAKE_C_FLAGS_RELEASE "${COMMON_FLAGS} -ffast-math -O2")
-
# Make sure the dylib install name path is set on OSX so you can include dumb in app bundles
IF(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set_target_properties(dumb PROPERTIES INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib)
@@ -108,12 +107,7 @@
../include/dumb.h
)
-IF(BUILD_SHARED)
- add_library(dumb SHARED ${SOURCES})
-ELSE(BUILD_SHARED)
- add_library(dumb STATIC ${SOURCES})
-ENDIF(BUILD_SHARED)
-
+add_library(dumb ${SOURCES})
set_target_properties(dumb PROPERTIES DEBUG_POSTFIX d)
INSTALL(FILES ${INSTALL_HEADERS} DESTINATION include/dumb/)
--- /dev/null
+++ b/dumb/cmake/readme.txt
@@ -1,0 +1,30 @@
+Howto build libdumb with cmake
+==============================
+
+A quick example
+---------------
+
+In libdumb cmake directory (dumb/cmake/), run:
+```
+mkdir -p build
+cd build
+cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_SHARED_LIBS:BOOL=ON ..
+make
+make install
+```
+
+Steps
+-----
+
+1. Create a new temporary build directory and cd into it
+2. Run libdumb cmake file with cmake (eg. `cmake -DCMAKE_INSTALL_PREFIX=/install/dir -DBUILD_SHARED_LIBS:BOOL=OFF -DCMAKE_BUILD_TYPE=Release path/to/dumb/cmake/dir`).
+3. Run make (eg. just `make` or `mingw32-make` or something).
+4. If needed, run make install.
+
+Flags
+-----
+
+* CMAKE_INSTALL_PREFIX sets the installation path prefix
+* CMAKE_BUILD_TYPE sets the build type (eg. Release, Debug, RelWithDebInfo, MinSizeRel). Debug libraries will be named libdumbd, release libraries libdumb.
+* BUILD_SHARED_LIBS selects whether cmake should build dynamic or static library (On=shared, OFF=static)
+* You may also need to tell cmake what kind of makefiles to create with the "-G" flag. Eg. for MSYS one would say something like `cmake -G "MSYS Makefiles" .`.