I am trying to create a static library of files with .inl
extension, but getting failed. If I change the extension to .cpp
then it builds.
CMakeLists.txt
cmake_minimum_required(VERSION 3.0.0)
project(CarSimulator VERSION 0.1.0 LANGUAGES C CXX)
include(CTest)
enable_testing()
add_library(printer
print.inl print.hpp
)
set_property(TARGET printer PROPERTY CXX_STANDARD 20)
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
print.hpp
#ifndef PRINT_H
#define PRINT_H
template<typename T>
void print(const T& t);
#include "print.cpp"
#endif
print.inl
#include <iostream>
template<typename T>
void print(const T& t) {
std::cout << t << std::endl;
}
Error
CMake Error: Cannot determine link language for target "printer".
CMake Error: CMake can not determine linker language for target: printer
-- Generating done
CMake Generate step failed. Build files cannot be regenerated correctly.
1