0

I want anyone who cloned the repository can build it immediately, and don't need to install the dependencies. Therefore, I found several ways:

  • Use git submodule and add_subdirectory.
  • Use find_package to find the built libraries and the headers.

The first one takes much time to build, so I think the second might be better. To make people be able to build the project instantly, I put the the files in the project, but it saied it doesn't know the linker language. What's this? And how to solve?

Direstories:

Project Root
  lib
    SDL2
      (generated files when install)
  include
    (headers)
  src
    (sources)
  CMakeLists.txt

CMakeLists.txt:

# ...

list(APPEND CMAKE_PREFIX_PATH lib)
find_package(SDL2)

# ...
Luminous
  • 51
  • 1
  • 4
  • > it saied it doesn't know the linker language; Please specify who is `it`, exact text of error and what exact command makes this error to appear. – The Dreams Wind May 10 '22 at 13:51
  • Note that both alternatives can be provided: simply add cmake configuration scripts to one directory in your project that use `add_subdirectory` for the appropriate submodule, should the target not yet exist. In your toplevel `CMakeLists.txt` before any `find_package` uses in your project do `list(APPEND CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}/path/to/configscript_root)` which allows the user of your project to provide paths to existing installations of projects which take precedence over the submodules. As for your issue: probably impossible to help without more info... – fabian May 10 '22 at 17:16
  • Does this answer your question? [CMake unable to determine linker language with C++](https://stackoverflow.com/questions/11801186/cmake-unable-to-determine-linker-language-with-c) – fabian May 10 '22 at 17:18
  • @TheDreamsWind sorry. the error message: CMake can not determine linker language for target: (project name) – Luminous May 11 '22 at 01:20
  • @fabian I think no. If I didn't understand incorrectly. – Luminous May 11 '22 at 01:24

0 Answers0