Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows build fails (using MinGW toolchain) #11

Open
adamski opened this issue Oct 17, 2019 · 3 comments
Open

Windows build fails (using MinGW toolchain) #11

adamski opened this issue Oct 17, 2019 · 3 comments

Comments

@adamski
Copy link

adamski commented Oct 17, 2019

I am getting a build error, from CLion using the MinGW toolchain, on Windows only. Builds on Mac without issues.

mingw32-make.exe[2]: *** No rule to make target 'my-lib/x86_64-pc-windows-msvc/debug/libmy_lib.a', needed by '<path-to-executable>/my-app.exe'.  Stop.
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:96: <path-to-app-project>/CMakeFiles/APP.dir/all] Error 2

It seems to be looking for a libmy_lib.a, when what is generated is my_lib.lib.

I have a top level CMakeLists.txt:

cmake_minimum_required(VERSION 3.14)
project(app)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")

enable_language(Rust)
include(CMakeCargo)

include_directories("include")

add_subdirectory("my-app")
add_subdirectory("my-lib")

target_link_libraries(APP PRIVATE
        my_lib
        $<$<PLATFORM_ID:Windows>:ws2_32>
        $<$<PLATFORM_ID:Windows>:userenv>
        )
@adamski
Copy link
Author

adamski commented Oct 17, 2019

OK, so using the variable_watch command, I saw the wrong prefix and suffix used to generate LIB_FILE. Adding the following lines under if(WIN32) in CMakeCargo.cmake seems to have solved the issue:

        set(CMAKE_STATIC_LIBRARY_PREFIX "")
        set(CMAKE_STATIC_LIBRARY_SUFFIX ".lib")

@awakecoding
Copy link
Contributor

can you add proper detection of MinGW to change the expected library suffix, while keeping proper support for MSVC builds?

@adamski
Copy link
Author

adamski commented Oct 17, 2019

Sure, I'll take a look at that and create a PR soon. I didn't realise MSVC builds used the libxx.a name format for static libraries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants