summaryrefslogtreecommitdiffstats
path: root/build/cmake
diff options
context:
space:
mode:
authorYann Collet <Cyan4973@users.noreply.github.com>2021-07-01 16:12:55 (GMT)
committerGitHub <noreply@github.com>2021-07-01 16:12:55 (GMT)
commitc240126068b780d927c126bb6a16cdeb92c35d77 (patch)
tree67f43d9d5ccf79a7af2b24df9cecff0332b4ee3b /build/cmake
parent11efc95c3f02b76ab40e7fbd605677ad6eb141d3 (diff)
parentafa7329622726e988fdf9d443362a6bf9f371815 (diff)
downloadlz4-c240126068b780d927c126bb6a16cdeb92c35d77.zip
lz4-c240126068b780d927c126bb6a16cdeb92c35d77.tar.gz
lz4-c240126068b780d927c126bb6a16cdeb92c35d77.tar.bz2
Merge pull request #1000 from lifegpc/patch1
fix link problem on win32 MSVC
Diffstat (limited to 'build/cmake')
-rw-r--r--build/cmake/CMakeLists.txt21
1 files changed, 14 insertions, 7 deletions
diff --git a/build/cmake/CMakeLists.txt b/build/cmake/CMakeLists.txt
index 7ce7be0..4b7b379 100644
--- a/build/cmake/CMakeLists.txt
+++ b/build/cmake/CMakeLists.txt
@@ -114,18 +114,21 @@ if(BUILD_SHARED_LIBS)
list(APPEND LZ4_LIBRARIES_BUILT lz4_shared)
endif()
if(BUILD_STATIC_LIBS)
+ set(STATIC_LIB_NAME lz4)
+ if (MSVC AND BUILD_SHARED_LIBS)
+ set(STATIC_LIB_NAME lz4_static)
+ endif()
add_library(lz4_static STATIC ${LZ4_SOURCES})
set_target_properties(lz4_static PROPERTIES
- OUTPUT_NAME lz4
+ OUTPUT_NAME ${STATIC_LIB_NAME}
POSITION_INDEPENDENT_CODE ${LZ4_POSITION_INDEPENDENT_LIB})
list(APPEND LZ4_LIBRARIES_BUILT lz4_static)
endif()
-# link to shared whenever possible, to static otherwise
-if(BUILD_SHARED_LIBS)
- set(LZ4_LINK_LIBRARY lz4_shared)
-else()
+if(BUILD_STATIC_LIBS)
set(LZ4_LINK_LIBRARY lz4_static)
+else()
+ list(APPEND LZ4_CLI_SOURCES ${LZ4_SOURCES})
endif()
# lz4
@@ -133,7 +136,9 @@ if (LZ4_BUILD_CLI)
set(LZ4_PROGRAMS_BUILT lz4cli)
add_executable(lz4cli ${LZ4_CLI_SOURCES})
set_target_properties(lz4cli PROPERTIES OUTPUT_NAME lz4)
- target_link_libraries(lz4cli ${LZ4_LINK_LIBRARY})
+ if (BUILD_STATIC_LIBS)
+ target_link_libraries(lz4cli ${LZ4_LINK_LIBRARY})
+ endif()
endif()
# lz4c
@@ -141,7 +146,9 @@ if (LZ4_BUILD_LEGACY_LZ4C)
list(APPEND LZ4_PROGRAMS_BUILT lz4c)
add_executable(lz4c ${LZ4_CLI_SOURCES})
set_target_properties(lz4c PROPERTIES COMPILE_DEFINITIONS "ENABLE_LZ4C_LEGACY_OPTIONS")
- target_link_libraries(lz4c ${LZ4_LINK_LIBRARY})
+ if (BUILD_STATIC_LIBS)
+ target_link_libraries(lz4c ${LZ4_LINK_LIBRARY})
+ endif()
endif()
# Extra warning flags