E1eveNn/xshinnosuke_cpp

vcproj 2 cmakelists.txt

Opened this issue · 1 comments

Hello, this my CMakeLists.txt for this project. When I build this project, something went wrong!

cmake_minimum_required(VERSION 3.16.0 FATAL_ERROR)

project(xshinnosuke CXX)

find_package(Eigen3 REQUIRED)

include_directories(${EIGEN3_INCLUDE_DIRS})

set(PROJECT_NAME xshinnosuke)

set(no_group_source_files
    "demo.cpp"
    "models.cpp"
    "models.h"
)
source_group("" FILES ${no_group_source_files})

set(layers
    "layers/activators.cpp"
    "layers/activators.h"
    "layers/base.cpp"
    "layers/base.h"
    "layers/linear.cpp"
    "layers/linear.h"
)
source_group("layers" FILES ${layers})

set(nn
    "nn/core.cpp"
    "nn/core.h"
    "nn/functional.cpp"
    "nn/functional.h"
    "nn/grad_fn.cpp"
    "nn/grad_fn.h"
    "nn/initializers.cpp"
    "nn/initializers.h"
    "nn/objectives.cpp"
    "nn/objectives.h"
    "nn/optimizers.cpp"
    "nn/optimizers.h"
)
source_group("nn" FILES ${nn})

set(test
    "test/dynamic_graph.h"
    "test/static_graph.h"
)
source_group("test" FILES ${test})

set(utils
    "utils/data.cpp"
    "utils/data.h"
    "utils/shape.cpp"
    "utils/shape.h"
    "utils/toolkit.cpp"
    "utils/toolkit.h"
)
source_group("utils" FILES ${utils})

set(ALL_FILES
    ${no_group_source_files}
    ${layers}
    ${nn}
    ${test}
    ${utils}
)

add_executable(${PROJECT_NAME} ${ALL_FILES})

Here is the report:

[build] : && /usr/bin/g++ -g  CMakeFiles/xshinnosuke.dir/demo.cpp.o CMakeFiles/xshinnosuke.dir/models.cpp.o CMakeFiles/xshinnosuke.dir/layers/activators.cpp.o CMakeFiles/xshinnosuke.dir/layers/base.cpp.o CMakeFiles/xshinnosuke.dir/layers/linear.cpp.o CMakeFiles/xshinnosuke.dir/nn/core.cpp.o CMakeFiles/xshinnosuke.dir/nn/functional.cpp.o CMakeFiles/xshinnosuke.dir/nn/grad_fn.cpp.o CMakeFiles/xshinnosuke.dir/nn/initializers.cpp.o CMakeFiles/xshinnosuke.dir/nn/objectives.cpp.o CMakeFiles/xshinnosuke.dir/nn/optimizers.cpp.o CMakeFiles/xshinnosuke.dir/utils/data.cpp.o CMakeFiles/xshinnosuke.dir/utils/shape.cpp.o CMakeFiles/xshinnosuke.dir/utils/toolkit.cpp.o -o xshinnosuke   && :
[build] /usr/bin/ld: CMakeFiles/xshinnosuke.dir/models.cpp.o: in function `Model::generate_graph()':
[build] /home/sugar/project/xshinnosuke_cpp/models.cpp:187:(.text+0x191c): undefined reference to `std::vector<Layer*, std::allocator<Layer*> > GlobalGraph::topological_sort<Layer>(Layer*, Layer*)'

Hello, this my CMakeLists.txt for this project. When I build this project, something went wrong!

cmake_minimum_required(VERSION 3.16.0 FATAL_ERROR)

project(xshinnosuke CXX)

find_package(Eigen3 REQUIRED)

include_directories(${EIGEN3_INCLUDE_DIRS})

set(PROJECT_NAME xshinnosuke)

set(no_group_source_files
    "demo.cpp"
    "models.cpp"
    "models.h"
)
source_group("" FILES ${no_group_source_files})

set(layers
    "layers/activators.cpp"
    "layers/activators.h"
    "layers/base.cpp"
    "layers/base.h"
    "layers/linear.cpp"
    "layers/linear.h"
)
source_group("layers" FILES ${layers})

set(nn
    "nn/core.cpp"
    "nn/core.h"
    "nn/functional.cpp"
    "nn/functional.h"
    "nn/grad_fn.cpp"
    "nn/grad_fn.h"
    "nn/initializers.cpp"
    "nn/initializers.h"
    "nn/objectives.cpp"
    "nn/objectives.h"
    "nn/optimizers.cpp"
    "nn/optimizers.h"
)
source_group("nn" FILES ${nn})

set(test
    "test/dynamic_graph.h"
    "test/static_graph.h"
)
source_group("test" FILES ${test})

set(utils
    "utils/data.cpp"
    "utils/data.h"
    "utils/shape.cpp"
    "utils/shape.h"
    "utils/toolkit.cpp"
    "utils/toolkit.h"
)
source_group("utils" FILES ${utils})

set(ALL_FILES
    ${no_group_source_files}
    ${layers}
    ${nn}
    ${test}
    ${utils}
)

add_executable(${PROJECT_NAME} ${ALL_FILES})

Here is the report:

[build] : && /usr/bin/g++ -g  CMakeFiles/xshinnosuke.dir/demo.cpp.o CMakeFiles/xshinnosuke.dir/models.cpp.o CMakeFiles/xshinnosuke.dir/layers/activators.cpp.o CMakeFiles/xshinnosuke.dir/layers/base.cpp.o CMakeFiles/xshinnosuke.dir/layers/linear.cpp.o CMakeFiles/xshinnosuke.dir/nn/core.cpp.o CMakeFiles/xshinnosuke.dir/nn/functional.cpp.o CMakeFiles/xshinnosuke.dir/nn/grad_fn.cpp.o CMakeFiles/xshinnosuke.dir/nn/initializers.cpp.o CMakeFiles/xshinnosuke.dir/nn/objectives.cpp.o CMakeFiles/xshinnosuke.dir/nn/optimizers.cpp.o CMakeFiles/xshinnosuke.dir/utils/data.cpp.o CMakeFiles/xshinnosuke.dir/utils/shape.cpp.o CMakeFiles/xshinnosuke.dir/utils/toolkit.cpp.o -o xshinnosuke   && :
[build] /usr/bin/ld: CMakeFiles/xshinnosuke.dir/models.cpp.o: in function `Model::generate_graph()':
[build] /home/sugar/project/xshinnosuke_cpp/models.cpp:187:(.text+0x191c): undefined reference to `std::vector<Layer*, std::allocator<Layer*> > GlobalGraph::topological_sort<Layer>(Layer*, Layer*)'

gcc: 13.2
eigen: 3.4
cmake: 3.29
ninja: 1.11