Reputation: 231
I know there are already a few threads on this topic, however, after reading through many of them I have been unable to find a solution to my problem. I am working on a file loader/parser and am using CMake for the first time. My CMakeList.txt file is being used to import an XML parser (xerces) and currently looks like:
cmake_minimum_required(VERSION 2.8)
project(fileloader)
set(SRCS
Source.cpp
)
include_directories(./
${SPF_ROOT}/xerces/win64/include/xercesc/dom
)
add_executables(${PROJECT_NAME} ${SRCS})
add_library(HEADER_ONLY_TARGET STATIC XMLString.hpp XercesDOMParser.hpp DOM.hpp HandlerBase.hpp PlatformUtils.hpp)
set_target_properties(HEADER_ONLY_TARGET PROPERTIES LINKER_LANGUAGE CXX)
When running my solution the error I am recieving is "CMake can not determine linker language for target: fileloader"
I am relatively new to c++ and completely new to CMake so hopefully I am missing something simple, but any and all help is greatly appreciated!
EDIT: The code I am writing is on a non-internet enabled machine so I cannot copy and paste the entire code, however this is the except causing the issue:
...
#include "XMLString.hpp"
#include "XercesDOMParser.hpp"
#include "DOM.hpp"
#include "HandlerBase.hpp"
#include "PlatformUtils.hpp"
class XMLReader : public IFileReader {
public:
XMLReader(){};
void read(std::ifstream& file) {
xerces::XMLPlatformUtils::Initialize();
xercesc::XercesDOMParser* parser = new xercesc::XercesDOMParser();
parser->setValidationScheme(xercesc::XercesDOMParser::Val_Always);
parser->setDoNamespaces(true);
xercesc::ErrorHandler* errHandler = (xercesc::ErrorHandler*) new xercesc::HandlerBase();
parser->setErrorHandler(errHandler);
std::getline(file, line);
newFile = line.c_str();
parser->parse(newFile);
}
}
...
Upvotes: 2
Views: 6229
Reputation: 231
Added: SET_TARGET_PROPERTIES([some name] PROPERTIES LINKER_LANGUAGE C11) to the end of my program and the error went away. After reading a million web pages I found https://kuniganotas.wordpress.com/2011/05/25/error-cmake-can-not-determine-linker-language-for-target/ and the solution was literally that simple! Hopefully this can help others with this error!
Upvotes: 3
Reputation: 69854
HEADER_ONLY_TARGET
is not a keyword argument.
If you want a header-only library, use an interface library:
add_library(<name> INTERFACE [IMPORTED [GLOBAL]])
Upvotes: 4