Skip to content

Commit

Permalink
build: name msvc artifact differently
Browse files Browse the repository at this point in the history
  • Loading branch information
kanru committed Jan 2, 2024
1 parent e019063 commit 6ec2f88
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
27 changes: 15 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()


Expand All @@ -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()

Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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

This comment has been minimized.

Copy link
@Chocobo1

Chocobo1 Jan 27, 2024

Member

@kanru
This rename here and commit 0e4beca broke compilation in downstream project.
In windows-chewing-tsf it expects a static library with the name chewing_static.lib. Source code here:
https://github.com/chewing/windows-chewing-tsf/blob/4a2303fab60e7859213547e6c129fc8da11ca262/ChewingTextService/CMakeLists.txt#L32
https://github.com/chewing/windows-chewing-tsf/blob/4a2303fab60e7859213547e6c129fc8da11ca262/chewingwrapper/CMakeLists.txt#L23

Any advice? Update windows-chewing-tsf to use the shared library (chewing-msvc)?

This comment has been minimized.

Copy link
@kanru

kanru Jan 27, 2024

Author Member

Ah, I missed this breaking change. My bad.

You can still build static library with the builtin BUILD_SHARED_LIBS option
cmake --preset default -DBUILD_SHARED_LIBS=false.

I recommend to use the shared library chewing-msvc because it exposes no internal symbols. However if windows-chewing-tsf uses internal symbols then static library is there for now. Note those symbols are going away once we switch to the Rust implementation which will only implement the public symbols.

Assume you may have used some internal symbols, we can discuss case by case if we can preserve them as public symbols in future releases.

)
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
Expand Down
7 changes: 1 addition & 6 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}\"
Expand Down

0 comments on commit 6ec2f88

Please sign in to comment.