I have different, precompiled versions of a 3rd-party library (Windows/Linux/Mac, 32/64-bit). It must be included in the project files to keep the requirements for compilation on other systems to a minimum and because I cannot expect it to be available for download years later. Both static and dynamic versions are available but no source.
How should I link it in my CMakeLists.txt
so that the dependent main.cpp
compiles on all systems? Would it work on different Linux distributions?
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(ExampleProject)
LINK_DIRECTORIES(${CMAKE_SOURCE_DIR}/libs)
ADD_EXECUTABLE(Test main.cpp)
TARGET_LINK_LIBRARIES(Test lib1_win32)
This works under Windows but obviously does not account for different operating systems and architectures. I know the alternatives to LINK_DIRECTORIES
, this is just an example.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…