i have problems with cmake and compiling my project with it.
my structure:
the error:
MSBuild version 17.8.3+195e7f5a3 for .NET Framework
1>Checking Build System
Building Custom Rule C:/Users/Flint/Desktop/carray/CMakeLists.txt
constructor.cpp
main.cpp
Generating Code...
main.obj : error LNK2019: unresolved external symbol "public: __cdecl CArray1<float>::CArray1<float>(void)" (??0?$CArray1@M@@QEAA@XZ) referenced in function main [C:\Users\Flint\Desktop\carray\build\main.vcxproj]
C:\Users\Flint\Desktop\carray\build\Debug\main.exe : fatal error LNK1120: 1 unresolved externals [C:\Users\Flint\Desktop\carray\build\main.vcxproj]
C:.
│ CMakeLists.txt
│ main.cpp
│
└───carray
└───carray1
│ carray1.hpp
│
└───property
└───constructor
constructor.cpp
main.cpp:
#include "carray/carray1/carray1.hpp"
int main() {
CArray1<float> x = CArray1<float>();
return 0;
}
carray1.hpp:
#ifndef CARRAY1_HPP
#define CARRAY1_HPP
template<typename T>
class CArray1 {
private:
T* _array;
size_t _size;
public:
CArray1();
};
#endif
constructor.cpp:
#include "../../carray1.hpp"
template<typename T>
CArray1<T>::CArray1() {
this->_array = new T();
this->_size = 0;
}
cmakelists.txt:
cmake_minimum_required(VERSION 3.12)
project(my_project)
file(GLOB_RECURSE all_files "*.cpp" EXCLUDE "build")
list(FILTER all_files EXCLUDE REGEX "build")
message(STATUS "Found source files:")
foreach(file IN LISTS all_files)
message(STATUS " ${file}")
endforeach(file)
add_executable(main ${all_files})