diff --git a/CMakeLists.txt b/CMakeLists.txt index 187bf73c4..398a168b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,7 +41,7 @@ if(CMAKE_C_COMPILER_ID MATCHES GNU|Clang) set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined ${CMAKE_SHARED_LINKER_FLAGS}") endif() endif() -elseif(CMAKE_C_COMPILER_ID MATCHES MSVC) +elseif(MSVC) # /wd4819 # Without BOM, Visual Studio does not treat source file as UTF-8 # encoding, thus it will complain about invalid character. Use @@ -54,8 +54,6 @@ elseif(CMAKE_C_COMPILER_ID MATCHES MSVC) if(MSVC_VERSION LESS 1900) add_compile_definitions(snprintf=_snprintf) endif() - - set(BUILD_SHARED_LIBS OFF) endif() @@ -70,7 +68,7 @@ add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}) option(WITH_SQLITE3 "Use sqlite3 to store userphrase" true) option(WITH_INTERNAL_SQLITE3 "Use internal sqlite3" false) -if(CMAKE_C_COMPILER_ID MATCHES MSVC) +if(MSVC) set(WITH_INTERNAL_SQLITE3 true) endif() @@ -274,7 +272,7 @@ if(NOT WITH_RUST) target_link_libraries(libchewing PRIVATE common PRIVATE userphrase) - if(BUILD_SHARED_LIBS AND CMAKE_C_COMPILER_ID MATCHES MSVC) + if(BUILD_SHARED_LIBS AND MSVC) target_compile_definitions(libchewing PRIVATE CHEWINGDLL_EXPORTS) endif() endif() @@ -297,7 +295,7 @@ if(WITH_RUST) PRIVATE LINKER:-exported_symbols_list,${CMAKE_BINARY_DIR}/symbols.map PRIVATE LINKER:-dead_strip ) - elseif(CMAKE_C_COMPILER_ID MATCHES MSVC) + elseif(MSVC) target_link_options(libchewing PRIVATE "/DEF ${CMAKE_BINARY_DIR}/symbols.map") set_target_properties(libchewing PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreadedDLL") endif() @@ -306,12 +304,17 @@ elseif(WITH_SQLITE3) target_link_libraries(libchewing PRIVATE ${SQLite3_LIBRARIES}) endif() - -set_target_properties(libchewing PROPERTIES - OUTPUT_NAME chewing - SOVERSION 3 - VERSION 3.3.1 -) +if(MSVC) + set_target_properties(libchewing PROPERTIES + OUTPUT_NAME chewing-msvc + ) +else() + set_target_properties(libchewing PROPERTIES + OUTPUT_NAME chewing + SOVERSION 3 + VERSION 3.3.1 + ) +endif() install(FILES ${ALL_INC} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/chewing) install(FILES ${PROJECT_BINARY_DIR}/chewing.pc diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c205e8c13..7be1d21a5 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -53,12 +53,7 @@ endif() foreach(target ${ALL_TESTS}) add_executable(${target} ${TEST_SRC_DIR}/${target}.c) target_link_libraries(${target} testhelper) - # XXX workaround MSVC issue - if(CMAKE_C_COMPILER_ID MATCHES MSVC AND WITH_RUST) - target_link_libraries(${target} chewing) - else() - target_link_libraries(${target} libchewing) - endif() + target_link_libraries(${target} libchewing) target_compile_definitions(${target} PRIVATE CHEWING_DATA_PREFIX=\"${DATA_BIN_DIR}\" TEST_HASH_DIR=\"${TEST_BIN_DIR}\"