aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt65
-rw-r--r--Makefile20
-rw-r--r--cmake-test/CMakeLists.txt9
-rw-r--r--src/CMakeLists.txt43
-rw-r--r--src/dlfcn.c (renamed from dlfcn.c)0
-rw-r--r--src/dlfcn.h (renamed from dlfcn.h)0
-rw-r--r--tests/CMakeLists.txt12
-rw-r--r--tests/test.c (renamed from test.c)0
-rw-r--r--tests/testdll.c (renamed from testdll.c)0
-rw-r--r--tests/testdll2.c (renamed from testdll2.c)0
-rw-r--r--tests/testdll3.c (renamed from testdll3.c)0
11 files changed, 74 insertions, 75 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e44343d..17d3fc4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,4 @@
1cmake_minimum_required(VERSION 2.8) 1cmake_minimum_required(VERSION 2.8.11)
2 2
3if (NOT DEFINED CMAKE_BUILD_TYPE) 3if (NOT DEFINED CMAKE_BUILD_TYPE)
4 set (CMAKE_BUILD_TYPE Release CACHE STRING "Build type") 4 set (CMAKE_BUILD_TYPE Release CACHE STRING "Build type")
@@ -9,65 +9,8 @@ project (dlfcn-win32 C)
9option(BUILD_SHARED_LIBS "shared/static libs" ON) 9option(BUILD_SHARED_LIBS "shared/static libs" ON)
10option(BUILD_TESTS "tests?" OFF) 10option(BUILD_TESTS "tests?" OFF)
11 11
12set(headers dlfcn.h) 12add_subdirectory(src)
13set(sources dlfcn.c)
14
15if (BUILD_SHARED_LIBS)
16 add_definitions(-DSHARED)
17endif (BUILD_SHARED_LIBS)
18
19add_library(dl ${sources})
20
21install (TARGETS dl EXPORT dlfcn-win32-targets
22 RUNTIME DESTINATION bin
23 LIBRARY DESTINATION lib${LIB_SUFFIX}
24 ARCHIVE DESTINATION lib${LIB_SUFFIX})
25
26install (FILES ${headers} DESTINATION include)
27
28# If CMake version is greater than or equal to 2.8.11
29# also install the cmake configuration files to simplify
30# the use of dlfcn-win32 in CMake
31if(NOT ${CMAKE_VERSION} VERSION_LESS "2.8.11")
32 # Correctly export the location of installed includes in the target
33 target_include_directories(dl INTERFACE $<INSTALL_INTERFACE:include>)
34
35 # Export the targets (build tree)
36 export(EXPORT dlfcn-win32-targets
37 FILE "${CMAKE_CURRENT_BINARY_DIR}/dlfcn-win32-targets.cmake"
38 NAMESPACE dlfcn-win32::
39 )
40
41 # Write the CMake config file
42 set(CMAKE_CONF_INSTALL_DIR share/dlfcn-win32)
43 set(INCLUDE_INSTALL_DIR include)
44 include(CMakePackageConfigHelpers)
45 configure_package_config_file(dlfcn-win32-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/dlfcn-win32-config.cmake
46 INSTALL_DESTINATION ${CMAKE_CONF_INSTALL_DIR}
47 PATH_VARS INCLUDE_INSTALL_DIR
48 NO_CHECK_REQUIRED_COMPONENTS_MACRO)
49
50 # Install the targets (install)
51 install(EXPORT dlfcn-win32-targets
52 FILE dlfcn-win32-targets.cmake
53 NAMESPACE dlfcn-win32::
54 DESTINATION ${CMAKE_CONF_INSTALL_DIR})
55
56 # Install the CMake config file
57 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/dlfcn-win32-config.cmake
58 DESTINATION ${CMAKE_CONF_INSTALL_DIR})
59endif()
60 13
61if (BUILD_TESTS) 14if (BUILD_TESTS)
62 enable_testing() 15 add_subdirectory(tests)
63 add_library(testdll SHARED testdll.c) 16endif()
64 set_target_properties(testdll PROPERTIES PREFIX "")
65 add_library(testdll2 SHARED testdll2.c)
66 set_target_properties(testdll2 PROPERTIES PREFIX "")
67 target_link_libraries(testdll2 dl)
68 add_library(testdll3 SHARED testdll3.c)
69 set_target_properties(testdll3 PROPERTIES PREFIX "")
70 add_executable(t_dlfcn test.c)
71 target_link_libraries(t_dlfcn dl)
72 add_test (NAME t_dlfcn COMMAND t_dlfcn)
73endif ()
diff --git a/Makefile b/Makefile
index 89c5d68..ab7279b 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@
2# dlfcn-win32 Makefile 2# dlfcn-win32 Makefile
3# 3#
4include config.mak 4include config.mak
5CFLAGS = -Wall -O3 -fomit-frame-pointer 5CFLAGS = -Wall -O3 -fomit-frame-pointer -Isrc
6 6
7ifeq ($(BUILD_SHARED),yes) 7ifeq ($(BUILD_SHARED),yes)
8 TARGETS += libdl.dll 8 TARGETS += libdl.dll
@@ -21,13 +21,13 @@ ifeq ($(BUILD_MSVC),yes)
21 INSTALL += lib-install 21 INSTALL += lib-install
22endif 22endif
23 23
24SOURCES := dlfcn.c 24SOURCES := src/dlfcn.c
25HEADERS := dlfcn.h 25HEADERS := src/dlfcn.h
26 26
27all: $(TARGETS) 27all: $(TARGETS)
28 28
29libdl.a: $(SOURCES) 29libdl.a: $(SOURCES)
30 $(CC) $(CFLAGS) -c $^ 30 $(CC) $(CFLAGS) -o $(^:%.c=%.o) -c $^
31 $(AR) cru $@ $(SOURCES:%.c=%.o) 31 $(AR) cru $@ $(SOURCES:%.c=%.o)
32 $(RANLIB) $@ 32 $(RANLIB) $@
33 33
@@ -58,19 +58,19 @@ lib-install:
58 58
59install: $(INSTALL) 59install: $(INSTALL)
60 60
61test.exe: test.c $(TARGETS) 61test.exe: tests/test.c $(TARGETS)
62 $(CC) $(CFLAGS) -o $@ $< libdl.dll.a 62 $(CC) $(CFLAGS) -o $@ $< libdl.dll.a
63 63
64test-static.exe: test.c $(TARGETS) 64test-static.exe: tests/test.c $(TARGETS)
65 $(CC) $(CFLAGS) -o $@ $< libdl.a 65 $(CC) $(CFLAGS) -o $@ $< libdl.a
66 66
67testdll.dll: testdll.c 67testdll.dll: tests/testdll.c
68 $(CC) $(CFLAGS) -shared -o $@ $^ 68 $(CC) $(CFLAGS) -shared -o $@ $^
69 69
70testdll2.dll: testdll2.c $(TARGETS) 70testdll2.dll: tests/testdll2.c $(TARGETS)
71 $(CC) $(CFLAGS) -shared -o $@ $< -L. -ldl 71 $(CC) $(CFLAGS) -shared -o $@ $< -L. -ldl
72 72
73testdll3.dll: testdll3.c 73testdll3.dll: tests/testdll3.c
74 $(CC) -shared -o $@ $^ 74 $(CC) -shared -o $@ $^
75 75
76test: $(TARGETS) $(TESTS) testdll.dll testdll2.dll testdll3.dll 76test: $(TARGETS) $(TESTS) testdll.dll testdll2.dll testdll3.dll
@@ -78,7 +78,7 @@ test: $(TARGETS) $(TESTS) testdll.dll testdll2.dll testdll3.dll
78 78
79clean:: 79clean::
80 rm -f \ 80 rm -f \
81 dlfcn.o \ 81 src/dlfcn.o \
82 libdl.dll libdl.a libdl.def libdl.dll.a libdl.lib libdl.exp \ 82 libdl.dll libdl.a libdl.def libdl.dll.a libdl.lib libdl.exp \
83 tmptest.c tmptest.dll \ 83 tmptest.c tmptest.dll \
84 test.exe test-static.exe testdll.dll testdll2.dll testdll3.dll 84 test.exe test-static.exe testdll.dll testdll2.dll testdll3.dll
diff --git a/cmake-test/CMakeLists.txt b/cmake-test/CMakeLists.txt
index 659a79a..b191317 100644
--- a/cmake-test/CMakeLists.txt
+++ b/cmake-test/CMakeLists.txt
@@ -1,19 +1,20 @@
1# Simple CMake project to test the use of dlfcn-win32 1# Simple CMake project to test the use of dlfcn-win32
2# imported target. The test compiled is the same compiled 2# imported target. The test compiled is the same compiled
3# as part of the main dlfcn-win32 project 3# as part of the main dlfcn-win32 project
4project(dlfcn-win32-test)
4 5
5cmake_minimum_required(VERSION 3.0) 6cmake_minimum_required(VERSION 3.0)
6 7
7find_package(dlfcn-win32 REQUIRED) 8find_package(dlfcn-win32 REQUIRED)
8 9
9add_library(testdll SHARED ../testdll.c) 10add_library(testdll SHARED ../tests/testdll.c)
10set_target_properties(testdll PROPERTIES PREFIX "") 11set_target_properties(testdll PROPERTIES PREFIX "")
11add_library(testdll2 SHARED ../testdll2.c) 12add_library(testdll2 SHARED ../tests/testdll2.c)
12set_target_properties(testdll2 PROPERTIES PREFIX "") 13set_target_properties(testdll2 PROPERTIES PREFIX "")
13target_link_libraries(testdll2 dlfcn-win32::dl) 14target_link_libraries(testdll2 dlfcn-win32::dl)
14add_library(testdll3 SHARED ../testdll3.c) 15add_library(testdll3 SHARED ../tests/testdll3.c)
15set_target_properties(testdll3 PROPERTIES PREFIX "") 16set_target_properties(testdll3 PROPERTIES PREFIX "")
16add_executable(t_dlfcn ../test.c) 17add_executable(t_dlfcn ../tests/test.c)
17target_link_libraries(t_dlfcn dlfcn-win32::dl) 18target_link_libraries(t_dlfcn dlfcn-win32::dl)
18enable_testing() 19enable_testing()
19add_test(NAME t_dlfcn COMMAND t_dlfcn) 20add_test(NAME t_dlfcn COMMAND t_dlfcn)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644
index 0000000..d5296b1
--- /dev/null
+++ b/src/CMakeLists.txt
@@ -0,0 +1,43 @@
1set(headers dlfcn.h)
2set(sources dlfcn.c)
3
4if (BUILD_SHARED_LIBS)
5 add_definitions(-DSHARED)
6endif (BUILD_SHARED_LIBS)
7
8add_library(dl ${sources})
9
10# Correctly export the location of installed includes in the target
11target_include_directories(dl INTERFACE $<INSTALL_INTERFACE:include>)
12
13install (TARGETS dl EXPORT dlfcn-win32-targets
14 RUNTIME DESTINATION bin
15 LIBRARY DESTINATION lib${LIB_SUFFIX}
16 ARCHIVE DESTINATION lib${LIB_SUFFIX})
17
18install (FILES ${headers} DESTINATION include)
19
20# Export the targets (build tree)
21export(EXPORT dlfcn-win32-targets
22 FILE "${CMAKE_BINARY_DIR}/dlfcn-win32-targets.cmake"
23 NAMESPACE dlfcn-win32::
24)
25
26# Write the CMake config file
27set(CMAKE_CONF_INSTALL_DIR share/dlfcn-win32)
28set(INCLUDE_INSTALL_DIR include)
29include(CMakePackageConfigHelpers)
30configure_package_config_file(../dlfcn-win32-config.cmake.in ${CMAKE_BINARY_DIR}/dlfcn-win32-config.cmake
31 INSTALL_DESTINATION ${CMAKE_CONF_INSTALL_DIR}
32 PATH_VARS INCLUDE_INSTALL_DIR
33 NO_CHECK_REQUIRED_COMPONENTS_MACRO)
34
35# Install the targets (install)
36install(EXPORT dlfcn-win32-targets
37 FILE dlfcn-win32-targets.cmake
38 NAMESPACE dlfcn-win32::
39 DESTINATION ${CMAKE_CONF_INSTALL_DIR})
40
41# Install the CMake config file
42install(FILES ${CMAKE_BINARY_DIR}/dlfcn-win32-config.cmake
43 DESTINATION ${CMAKE_CONF_INSTALL_DIR})
diff --git a/dlfcn.c b/src/dlfcn.c
index 532af91..532af91 100644
--- a/dlfcn.c
+++ b/src/dlfcn.c
diff --git a/dlfcn.h b/src/dlfcn.h
index 9ddbba3..9ddbba3 100644
--- a/dlfcn.h
+++ b/src/dlfcn.h
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
new file mode 100644
index 0000000..64f85f7
--- /dev/null
+++ b/tests/CMakeLists.txt
@@ -0,0 +1,12 @@
1enable_testing()
2include_directories(../src)
3add_library(testdll SHARED testdll.c)
4set_target_properties(testdll PROPERTIES PREFIX "")
5add_library(testdll2 SHARED testdll2.c)
6set_target_properties(testdll2 PROPERTIES PREFIX "")
7target_link_libraries(testdll2 dl)
8add_library(testdll3 SHARED testdll3.c)
9set_target_properties(testdll3 PROPERTIES PREFIX "")
10add_executable(t_dlfcn test.c)
11target_link_libraries(t_dlfcn dl)
12add_test (NAME t_dlfcn COMMAND t_dlfcn)
diff --git a/test.c b/tests/test.c
index 5d060d2..5d060d2 100644
--- a/test.c
+++ b/tests/test.c
diff --git a/testdll.c b/tests/testdll.c
index 5bb0f43..5bb0f43 100644
--- a/testdll.c
+++ b/tests/testdll.c
diff --git a/testdll2.c b/tests/testdll2.c
index 1560738..1560738 100644
--- a/testdll2.c
+++ b/tests/testdll2.c
diff --git a/testdll3.c b/tests/testdll3.c
index b6f4f5b..b6f4f5b 100644
--- a/testdll3.c
+++ b/tests/testdll3.c