0

I am trying to build a code using Cmake. The source code is available in this link. To build the code I am following the instructions given in BuildingInstructions.txt file contained in the ElasticSewingMachine but I get the following error message when running `ccmake ..`` in ElasticSewingMachine/BASim/build:

CMake Error at src/CMakeLists.txt:24 (append_files):
   Unknown CMake command "append_files".

 CMake Warning (dev) in CMakeLists.txt:
   No cmake_minimum_required command is present.  A line of code such as

     cmake_minimum_required(VERSION 3.18)

   should be added at the top of the file.  The version specified may be lower
   if you wish to support older CMake versions for this project.

I had a look at this link but since there are various CMakeLists.txt I couldn't figure out which one is supposed to be the top-level one? There is one CMakeLists.txt in BASim directory which contains only one line. There is another one in BASim/src which contains the following code

find_package (OpenGL REQUIRED)
include_directories (${OPENGL_INCLUDE_DIR})
set (DEFAULT_LIBRARIES ${DEFAULT_LIBRARIES} ${OPENGL_LIBRARIES})

find_package (GLUT REQUIRED glut)
include_directories (${GLUT_INCLUDE_DIR})
set (DEFAULT_LIBRARIES ${DEFAULT_LIBRARIES} ${GLUT_glut_LIBRARY})

set (Directories
  .
  Core
  Core/TopologicalObject
  Collisions
  IO
  Math
  Physics
  Physics/ElasticRods
  Render
  Util
)

include_directories (${CMAKE_CURRENT_SOURCE_DIR})

append_files (Headers "hh" ${Directories})
append_files (Inlines "inl" ${Directories})
append_files (Templates "tcc" ${Directories})
append_files (Sources "cc" ${Directories})

if (PNG_FOUND)
  set (Headers ${Headers} Render/YImage/YImage.hh)
  set (Sources ${Sources} Render/YImage/YImage.cc)
endif (PNG_FOUND)
if (PETSC_FOUND)
  append_files (Headers "hh" Math/Petsc)
  append_files (Inlines "inl" Math/Petsc)
  append_files (Templates "tcc" Math/Petsc)
  append_files (Sources "cc" Math/Petsc)
endif (PETSC_FOUND)

if (MKL_FOUND)
  append_files (Headers "hh" Math/MKL)
  append_files (Inlines "inl" Math/MKL)
  append_files (Templates "tcc" Math/MKL)
  append_files (Sources "cc" Math/MKL)
endif (MKL_FOUND)

if (LAPACK_FOUND)
  append_files (Headers "hh" Math/MKL)
  append_files (Inlines "inl" Math/MKL)
  append_files (Templates "tcc" Math/MKL)
  append_files (Sources "cc" Math/MKL)
endif (LAPACK_FOUND)

if (PARDISO_FOUND)
  append_files (Headers "hh" Math/Pardiso)
  append_files (Inlines "inl" Math/Pardiso)
  append_files (Templates "tcc" Math/Pardiso)
  append_files (Sources "cc" Math/Pardiso)
endif (PARDISO_FOUND)

if (TEST_ROD_STRETCHING_FORCE)
  add_definitions (-DTEST_ROD_STRETCHING)
  set (Headers ${Headers} Physics/ElasticRods/Tests/RodStretchingTest.hh)
  set (Inlines ${Inlines} Physics/ElasticRods/Tests/stretchingEnergy.inl)
  set (Inlines ${Inlines} Physics/ElasticRods/Tests/stretchingForce.inl)
  set (Inlines ${Inlines} Physics/ElasticRods/Tests/stretchingJacobian.inl)
endif (TEST_ROD_STRETCHING_FORCE)
if (TEST_ROD_TWISTING_FORCE)
  add_definitions (-DTEST_ROD_TWISTING)
  set (Headers ${Headers} Physics/ElasticRods/Tests/RodTwistingTest.hh)
  set (Inlines ${Inlines} Physics/ElasticRods/Tests/twistingEnergy.inl)
  set (Inlines ${Inlines} Physics/ElasticRods/Tests/twistingForce.inl)
  set (Inlines ${Inlines} Physics/ElasticRods/Tests/twistingJacobian.inl)
endif (TEST_ROD_TWISTING_FORCE)

if (TEST_ROD_BENDING_FORCE)
  add_definitions (-DTEST_ROD_BENDING)
  set (Headers ${Headers} Physics/ElasticRods/Tests/RodBendingTest.hh)
  set (Inlines ${Inlines} Physics/ElasticRods/Tests/bendingEnergy.inl)
  set (Inlines ${Inlines} Physics/ElasticRods/Tests/bendingForce.inl)
  set (Inlines ${Inlines} Physics/ElasticRods/Tests/bendingJacobian.inl)
  set (Sources ${Sources} Physics/ElasticRods/Tests/RodBendingTest.cc)
endif (TEST_ROD_BENDING_FORCE)

add_library (BASim SHARED ${Headers} ${Inlines} ${Templates} ${Sources})
target_link_libraries (BASim ${DEFAULT_LIBRARIES})

I assume this might be the top-level CMakeLists.txt, although I added the line cmake_minimum_required(VERSION 3.18) on the top of both files the error persists.

I am not sure what I am doing wrong here, would you share your thoughts on this with me please? I am working on Ubuntu 18.04.

Dude
  • 191
  • 3
  • 12
  • `I assume this might be the top-level` So what if that assumption is wrong? – KamilCuk Nov 04 '20 at 21:31
  • @KamilCuk, I will happily drop my assumption and will welcome knowing the right top-level CMakeLists.txt. ;) so tell me, which one is the top-level one? How should I figure out which one is top-level? – Dude Nov 04 '20 at 21:36
  • Find one with `cmake_minimum_required`. Or maybe none and this project is meant to be included from an other project. No idea - what project is it? Is it open sources? Are sources available publicly? – KamilCuk Nov 04 '20 at 21:39
  • Yes it is open source and publicly available, just open the link I shared in the first line, there on the bottom of the page you find the source code C++ – Dude Nov 04 '20 at 21:44
  • The first line of the **top-level** `CMakeLists.txt` is `cmake_minimum_required (VERSION 2.6)`. You should build the project using this directory as the source one. – Tsyvarev Nov 04 '20 at 22:14
  • @Tsyvarev, How did you come up with version 2.6.? how do I figure which CMakeLists.txt is the top-level? there is one CMakeLists.txt in `/BASim` , there is another one in `/BASim/src`, which one is the top level? – Dude Nov 05 '20 at 21:35
  • I just downloaded the archive from the link you provide (at `Source:` line). Top-level `CMakeLists.txt` in the archive contains the required line. – Tsyvarev Nov 05 '20 at 22:40
  • @Tsyvarev, cool thanks for showing the file. Although were you able to build the project? in the `BuildingInstruction.txt` file it mentions that I should run `ccmake ..` in `build` directory and this command doesn't refer to the top-level CMakeLists.txt you are refering to, I also moved the top-level file to BASim directory to be taken into account when I run `ccmake ..` still no success, some other type of error. So could you verify whether you are able to build the project using the instruction provided please? – Dude Nov 07 '20 at 18:22
  • No, I haven't tried to build the project. Nor I want to do that. As only the top-level `CMakeLists.txt` contains `cmake_minimum_required` call, then exactly the top-level directory should be used as a source one. If the documentation claims the opposite ("Go into the BASim directory. First, create a directory called build, and switch to it."), then the documentation is simply wrong. – Tsyvarev Nov 07 '20 at 22:17

1 Answers1

-1

In CMake space keys matters most as a separator like a comma Instead of Writing

cmake_minimum_requirement(VERSION 3.22.1)

Write this ; it makes all the difference

cmake_minimum_required (VERSION 3.22.1)

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 17 '23 at 03:26