瀏覽代碼

Initial CMake infrastructure.

Ioannis Koutras 13 年之前
父節點
當前提交
f58ec4f19f
共有 11 個文件被更改,包括 91 次插入2 次删除
  1. 45 0
      CMakeLists.txt
  2. 1 0
      DefineOptions.cmake
  3. 22 0
      cmake/Modules/COPYING-CMAKE-SCRIPTS
  4. 17 0
      cmake/Modules/MacroEnsureOutOfSourceBuild.cmake
  5. 1 0
      custom_free.c
  6. 1 0
      custom_malloc.c
  7. 1 0
      dmm_config.h.in
  8. 1 0
      dmm_init.c
  9. 1 0
      heap.h
  10. 0 2
      posix_lock.c
  11. 1 0
      sys_alloc.c

+ 45 - 0
CMakeLists.txt

@@ -0,0 +1,45 @@
+project (dmmlib C)
+
+cmake_minimum_required (VERSION 2.6)
+
+set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
+
+include(DefineOptions.cmake)
+
+include(MacroEnsureOutOfSourceBuild)
+macro_ensure_out_of_source_build("${PROJECT_NAME} requires an out of source build. Please create a separate build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there.")
+
+configure_file (
+	"${PROJECT_SOURCE_DIR}/dmm_config.h.in"
+	"${PROJECT_BINARY_DIR}/dmm_config.h"
+)
+
+include_directories("${PROJECT_BINARY_DIR}")
+
+#add_subdirectory(src)
+
+set(DMMLIB_SHARED_LIBRARY
+  dmm_shared
+  CACHE INTERNAL "dmmlib shared library"
+)
+
+set(dmmlib_SRCS
+	block_header.c
+	coalesce.c
+	custom_free.c
+	custom_malloc.c
+	dmm_adaptor.c
+	dmm_init.c
+	other.c
+	sys_alloc.c
+)
+
+if (HAVE_LOCKS)
+	set(dmmlib_SRCS
+		${dmmlib_SRCS}
+		posix_lock.c
+	)
+endif (HAVE_LOCKS)
+
+add_library(${DMMLIB_SHARED_LIBRARY} SHARED ${dmmlib_SRCS})
+

+ 1 - 0
DefineOptions.cmake

@@ -0,0 +1 @@
+option(HAVE_LOCKS "Build with POSIX locking mechanisms" ON)

+ 22 - 0
cmake/Modules/COPYING-CMAKE-SCRIPTS

@@ -0,0 +1,22 @@
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. The name of the author may not be used to endorse or promote products 
+   derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ 17 - 0
cmake/Modules/MacroEnsureOutOfSourceBuild.cmake

@@ -0,0 +1,17 @@
+# - MACRO_ENSURE_OUT_OF_SOURCE_BUILD(<errorMessage>)
+# MACRO_ENSURE_OUT_OF_SOURCE_BUILD(<errorMessage>)
+
+# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+macro (MACRO_ENSURE_OUT_OF_SOURCE_BUILD _errorMessage)
+
+   string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" _insource)
+   if (_insource)
+     message(SEND_ERROR "${_errorMessage}")
+     message(FATAL_ERROR "Remove the file CMakeCache.txt in ${CMAKE_SOURCE_DIR} first.")
+   endif (_insource)
+
+endmacro (MACRO_ENSURE_OUT_OF_SOURCE_BUILD)

+ 1 - 0
custom_free.c

@@ -1,4 +1,5 @@
 #include "custom_free.h"
+#include "dmm_config.h"
 #include "other.h"
 #ifdef HAVE_LOCKS
 #include "posix_lock.h"

+ 1 - 0
custom_malloc.c

@@ -1,4 +1,5 @@
 #include "custom_malloc.h"
+#include "dmm_config.h"
 #ifdef HAVE_LOCKS
 #include "posix_lock.h"
 #endif /* HAVE_LOCKS */

+ 1 - 0
dmm_config.h.in

@@ -0,0 +1 @@
+#cmakedefine HAVE_LOCKS

+ 1 - 0
dmm_init.c

@@ -1,4 +1,5 @@
 #include <unistd.h>
+#include "dmm_config.h"
 #ifdef HAVE_LOCKS
 #include <pthread.h>
 #endif /* HAVE_LOCKS */

+ 1 - 0
heap.h

@@ -9,6 +9,7 @@
 #define HEAP_H
 
 #include <stdint.h>
+#include "dmm_config.h"
 #ifdef HAVE_LOCKS
 #include <pthread.h>
 #endif /* HAVE_LOCKS */

+ 0 - 2
posix_lock.c

@@ -1,4 +1,3 @@
-#ifdef HAVE_LOCKS
 #include <pthread.h>
 #include "posix_lock.h"
 
@@ -19,5 +18,4 @@ void posix_lock(heap_t *heap) {
 void posix_unlock(heap_t *heap) {
     pthread_mutex_unlock(&heap->mutex);
 }
-#endif /* HAVE_LOCKS */
 

+ 1 - 0
sys_alloc.c

@@ -2,6 +2,7 @@
 #include <stdio.h>
 #include <errno.h>
 #include <string.h>
+#include "dmm_config.h"
 #ifdef HAVE_LOCKS
 #include "posix_lock.h"
 #endif /* HAVE_LOCKS */