aboutsummaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-05-17 09:13:55 -0700
committerChris Robinson <[email protected]>2011-05-17 09:13:55 -0700
commit60965e3a6c0bcf719a3dc266beccda4c4f560a72 (patch)
tree60ce197d76fa1a36e780813975744c0a6dafaa40 /CMakeLists.txt
parentb5cb2d633c5df80128ce7fb08064c1f8df1dd731 (diff)
Determine the function export attribute using CMake
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt52
1 files changed, 27 insertions, 25 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7cf3db78..a46160cb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -60,6 +60,8 @@ SET(LIB_MAJOR_VERSION "1")
SET(LIB_MINOR_VERSION "13")
SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}")
+SET(EXPORT_DECL "")
+
CHECK_TYPE_SIZE("long" SIZEOF_LONG)
CHECK_TYPE_SIZE("long long" SIZEOF_LONG_LONG)
@@ -144,34 +146,34 @@ ELSE()
CHECK_C_SOURCE_COMPILES("int foo() __attribute__((destructor));
int main() {return 0;}" HAVE_GCC_DESTRUCTOR)
+ENDIF()
- # Set visibility options if available
- IF(NOT WIN32)
- CHECK_C_COMPILER_FLAG(-fvisibility=internal HAVE_VISIBILITY_SWITCH)
- IF(HAVE_VISIBILITY_SWITCH)
- CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"default\")));
- int main() {return 0;}" HAVE_GCC_VISIBILITY)
- IF(HAVE_GCC_VISIBILITY)
- ADD_DEFINITIONS(-fvisibility=internal -DHAVE_GCC_VISIBILITY)
- ENDIF()
- ENDIF()
- ELSE()
- OPTION(WINE "Enable use of Wine headers when compiling" ON)
- IF(WINE)
- FIND_PATH(WINE_INCLUDE_DIR library.h
- PATHS
- /usr/include/wine
- /usr/local/include/wine
- PATH_SUFFIXES ".")
- IF(WINE_INCLUDE_DIR)
- MESSAGE(STATUS "Found Wine header files - ${WINE_INCLUDE_DIR}" )
- INCLUDE_DIRECTORIES("${WINE_INCLUDE_DIR}/windows")
- SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} "${WINE_INCLUDE_DIR}/windows")
- ELSE()
- MESSAGE(STATUS "Could not find Wine header files" )
- ENDIF()
+# Set visibility/export options if available
+IF(WIN32)
+ SET(EXPORT_DECL "__declspec(dllexport)")
+
+ OPTION(WINE "Enable use of Wine headers when compiling" ON)
+ IF(WINE)
+ FIND_PATH(WINE_INCLUDE_DIR library.h
+ PATHS
+ /usr/include/wine
+ /usr/local/include/wine)
+ IF(WINE_INCLUDE_DIR)
+ MESSAGE(STATUS "Found Wine header files - ${WINE_INCLUDE_DIR}" )
+ INCLUDE_DIRECTORIES("${WINE_INCLUDE_DIR}/windows")
+ SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} "${WINE_INCLUDE_DIR}/windows")
+ ELSE()
+ MESSAGE(STATUS "Could not find Wine header files" )
ENDIF()
ENDIF()
+ELSE()
+ CHECK_C_COMPILER_FLAG(-fvisibility=internal HAVE_VISIBILITY_SWITCH)
+ CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"protected\")));
+ int main() {return 0;}" HAVE_GCC_VISIBILITY)
+ IF(HAVE_VISIBILITY_SWITCH AND HAVE_GCC_VISIBILITY)
+ ADD_DEFINITIONS(-fvisibility=internal)
+ SET(EXPORT_DECL "__attribute__((visibility(\"protected\")))")
+ ENDIF()
ENDIF()
CHECK_C_SOURCE_COMPILES("int foo(const char *str, ...) __attribute__((format(printf, 1, 2)));