AmokHuginnsson / replxx

A readline and libedit replacement that supports UTF-8, syntax highlighting, hints and Windows and is BSD licensed.
Other
691 stars 108 forks source link

Using target_link_libraries to pass in linker flags is incorrect #64

Closed DrChat closed 3 years ago

DrChat commented 4 years ago

https://github.com/AmokHuginnsson/replxx/blob/ae65cae141fbdc9d96ac17564b0cb81543c9eaab/CMakeLists.txt#L103-L109

We ran into this recently - these flags were passed into the linker as objects rather than flags (fatal error LNK1104: cannot open file '\ignore:4099.obj')

AmokHuginnsson commented 4 years ago

Can you tell me which cmake version you have? And how you run it.

DrChat commented 4 years ago

Version 3.12.3 We're including replxx as an ExternalProject.

ExternalProject_Add(
  PREFIX ${CMAKE_CURRENT_BINARY_DIR}/_prefix/replxx
  SOURCE_DIR ${CMAKE_SOURCE_DIR}/third_party/replxx
  CMAKE_ARGS += -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
    -DCMAKE_INSTALL_PREFIX=${THIRDPARTY_INSTALL_DIR}/replxx
    -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${CMAKE_BINARY_DIR}
    -Wno-dev
    -DBUILD_STATIC_LIBS=ON
    -DBUILD_SHARED_LIBS=OFF
  EXCLUDE_FROM_ALL TRUE
)

There's more lines but I think those are the most relevant.

Edit: Also important to note that we're running on Windows + Visual Studio 2019.

nnmm79 commented 4 years ago

Had similar problem on my script when using like that: target_link_options(${BIN_NAME} PUBLIC PRIVATE ignore:4099 ) After adding / character before ignore it started working: target_link_options(${BIN_NAME} PUBLIC PRIVATE /ignore:4099 ) I know it is old task, but if it helps anyone it is worth it.

AmokHuginnsson commented 4 years ago

@nnmm79 Do you use current master? I cannot find target_link_options(${BIN_NAME} PUBLIC PRIVATE ignore:4099 ) in the code.

nnmm79 commented 4 years ago

I apologize I was no clear enough. Code I pasted is not a part of your project, it was suggested as sample for a solution for an issue reported by @DrChat. Since in their code I see cmake-generator-expression I gave my example, because I do not understand generator expression syntax enough to be confident that I will do it correctly without testing. And because this is the only google result for given error and task is still open I decided to post a solution. To possibly help.

AmokHuginnsson commented 3 years ago

I cannot reproduce this issue with CMake 3.16.4.