diff --git a/CHANGELOG.mkd b/CHANGELOG.mkd index becbdc1..c132f52 100644 --- a/CHANGELOG.mkd +++ b/CHANGELOG.mkd @@ -19,6 +19,11 @@ Added: by and included with RPythonic http://code.google.com/p/rpythonic/ Thanks to hartsantler for this feature. +- Ability to build as a static library - must define WIIUSE_STATIC in + client app as well as choosing the appropriate option when building + WiiUse. The default is still a shared library (dll/so). Merged from + paulburton and added to build system. + Fixed: - Properly disable rumbling when told to. Thanks to Jeff Baker from diff --git a/CMakeLists.txt b/CMakeLists.txt index 982e261..545d199 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,7 @@ message(STATUS "Configuring WiiUse version ${CPACK_PACKAGE_VERSION}") option(BUILD_EXAMPLE "Should we build the example app?" YES) option(BUILD_EXAMPLE_SDL "Should we build the SDL-based example app?" YES) +option(BUILD_WIIUSE_SHARED_LIB "Should we build as a shared library (dll/so)?" YES) option(INSTALL_EXAMPLES "Should we install the example apps?" YES) option(CPACK_MONOLITHIC_INSTALL "Only produce a single component installer, rather than multi-component." NO) @@ -29,7 +30,12 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") include(UseBackportedModules) include(DoxygenTargets) -add_definitions(-DWIIUSE_COMPILE_LIB) +if(BUILD_WIIUSE_SHARED_LIB) + set(WIIUSE_LIB_TYPE SHARED) +else() + set(WIIUSE_LIB_TYPE STATIC) + add_definitions(-DWIIUSE_STATIC) +endif() if(NOT WIN32 AND NOT APPLE) set(LINUX YES) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 07bcde4..b4572b7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -34,7 +34,9 @@ if(MSVC) list(APPEND API wiiuse_msvcstdint.h) endif() -add_library(wiiuse SHARED ${SOURCES} ${API}) +add_definitions(-DWIIUSE_COMPILE_LIB) + +add_library(wiiuse ${WIIUSE_LIB_TYPE} ${SOURCES} ${API}) if(WIN32) target_link_libraries(wiiuse ws2_32 setupapi ${WINHID_LIBRARIES}) diff --git a/src/wiiuse.h b/src/wiiuse.h index d820d3e..d092b44 100644 --- a/src/wiiuse.h +++ b/src/wiiuse.h @@ -727,8 +727,13 @@ typedef enum wiiuse_loglevel { *****************************************/ #ifdef WIIUSE_WIN32 - #define WIIUSE_EXPORT_DECL __declspec(dllexport) - #define WIIUSE_IMPORT_DECL __declspec(dllimport) + #ifdef WIIUSE_STATIC + #define WIIUSE_EXPORT_DECL + #define WIIUSE_IMPORT_DECL + #else + #define WIIUSE_EXPORT_DECL __declspec(dllexport) + #define WIIUSE_IMPORT_DECL __declspec(dllimport) + #endif #else #define WIIUSE_EXPORT_DECL #define WIIUSE_IMPORT_DECL