From 909f214d6b1c85a4a6b4390fcf903d0d21ed3600 Mon Sep 17 00:00:00 2001 From: Adam Wardynski <award@.(win7-laptop)> Date: Sat, 13 Nov 2010 21:31:01 +0100 Subject: [PATCH] Make add_library use default setting which is set to SHARED libs for anything but WIN32. WIN32 libs are going to be STATIC until external API is specifically defined (Windows' DLLs export nothing by default, UNIX shared libs export everything) --- CMakeLists.txt | 18 ++++++++++++++++++ libcorpus2/CMakeLists.txt | 2 +- libpwrutils/CMakeLists.txt | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 957ae54..8a2d104 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,6 +53,24 @@ FIND_PATH(LIBCORPUS2_SRC_DATA_DIR ) MARK_AS_ADVANCED(LIBCORPUS2_SRC_DATA_DIR) +# For DLLs on Windows (aka SHARED libraries) you have to explicitly +# specify the external API of the library. Nothing is exported +# by default. +# For UNIX on the other hand everything is exported by default. +# We were building libraries SHARED but without specyfing +# external API. It worked on UNIX but not on Windows. +# This is changed now so add_library entries do not specify library +# type and therefore use default. Below, the default is set +# to build SHARED libs on anything but WIN32, so for Windows/cygwin +# we are building STATIC (todo: is cygwin ok w/o externs?) +# To make DLLs on Windows, exports have to be defined and then +# add_library entry changed to state SHARED for given library. +# Once this is done for all libraries, and all are marked +# explicitly as SHARED, the below will won't make a difference. +if(NOT WIN32) + set(BUILD_SHARED_LIBS TRUE) +endif(NOT WIN32) + add_subdirectory(libpwrutils) add_subdirectory(libcorpus2) add_subdirectory(tagset-tool) diff --git a/libcorpus2/CMakeLists.txt b/libcorpus2/CMakeLists.txt index ae39d3b..b9d669f 100644 --- a/libcorpus2/CMakeLists.txt +++ b/libcorpus2/CMakeLists.txt @@ -68,7 +68,7 @@ SET(libcorpus2_STAT_SRC file(GLOB_RECURSE INCS "*.h") -add_library(corpus2 SHARED ${libcorpus2_STAT_SRC} ${INCS}) +add_library(corpus2 ${libcorpus2_STAT_SRC} ${INCS}) target_link_libraries(corpus2 ${LIBS}) set_target_properties(corpus2 PROPERTIES VERSION "${corpus2_ver_major}.${corpus2_ver_minor}" diff --git a/libpwrutils/CMakeLists.txt b/libpwrutils/CMakeLists.txt index 84cbcc8..0e969a0 100644 --- a/libpwrutils/CMakeLists.txt +++ b/libpwrutils/CMakeLists.txt @@ -34,7 +34,7 @@ SET(libpwrutils_STAT_SRC file(GLOB_RECURSE INCS "*.h") -add_library(pwrutils SHARED ${libpwrutils_STAT_SRC} ${INCS}) +add_library(pwrutils ${libpwrutils_STAT_SRC} ${INCS}) target_link_libraries(pwrutils ${LIBS} ) set_target_properties(pwrutils PROPERTIES VERSION "${pwrutils_ver_major}.${pwrutils_ver_minor}" -- GitLab