Commit 6a6ebd39e522922aa493552961d4b599f1e83805

Timothy Gu 2014-09-23T17:28:16

Merge pull request #3 from xantares/cmake Initial cmake port

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..e8731d2
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,30 @@
+project (dlfcn C)
+
+cmake_minimum_required(VERSION 2.8)
+
+option(BUILD_SHARED_LIBS "shared/static libs" ON) 
+option(USE_WINE "use wine for test" ON)
+option(BUILD_TESTS "tests?" OFF)
+
+set(headers dlfcn.h)
+set(sources dlfcn.c)
+
+add_library(dl ${sources})
+
+install (TARGETS dl RUNTIME DESTINATION bin
+                    LIBRARY DESTINATION lib${LIB_SUFFIX}
+                    ARCHIVE DESTINATION lib${LIB_SUFFIX})
+
+install (FILES ${headers} DESTINATION include)
+
+if (BUILD_TESTS)
+  enable_testing()
+  if (USE_WINE)
+    find_program(WINE_EXECUTABLE NAMES wine)
+  endif ()
+  add_library(testdll SHARED testdll.c)
+  set_target_properties(testdll PROPERTIES PREFIX "")
+  add_executable(t_dlfcn test.c)
+  target_link_libraries(t_dlfcn dl)
+  add_test ( NAME t_dlfcn COMMAND ${WINE_EXECUTABLE} t_dlfcn${CMAKE_EXECUTABLE_SUFFIX} )
+endif ()