CHAI3DCHAI3D

normal How do I configure a the project with Cmake

More
28 Apr 2016 18:42 #1

I want to compile and run the example (13 - primitives ), but I want to configure the dependencies using Cmake. I I used the provided Cmakelists file that is located in the examples directory.


if (CMAKE_SYSTEM_NAME MATCHES Windows)
  include_directories (${FREEGLUT_INCLUDE_DIRS})
  set (GLUT_LIBRARIES ${FREEGLUT_LIBRARIES})
else ()
  find_package (GLUT REQUIRED)
endif ()

# build all targets
foreach (example 01-mydevice 02-multi-devices 03-analytics 04-shapes 05-fonts 06-images 07-mouse-select 08-shaders 09-magnets 10-oring 11-effects 12-polygons 13-primitives 14-textures 15-paint 16-friction 17-shading 18-endoscope 19-space 20-map 21-object 22-chrome 23-tooth 24-turntable 25-sounds 26-video 27-multiframes 28-voxel-basic 29-voxel-isosurface 30-voxel-colormap 31-pointcloud)

  file (GLOB source ${example}/*.cpp)
  add_executable (${example} ${source})
  target_link_libraries (${example} ${CHAI3D_LIBRARIES} ${GLUT_LIBRARIES})
  
  # OS specific adjustments
  if (CMAKE_SYSTEM_NAME MATCHES Darwin)
    add_custom_command (TARGET ${example} POST_BUILD COMMAND Rez -append ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/../resources/icons/chai3d.rsrc -o ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${example} COMMAND SetFile -a C ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${example} VERBATIM)
  endif ()

endforeach ()


and I generated the solution file but the problem is that the visual studio doesn't find the include files (.h) as you can see the red error lines in the picture. So What am I missing in the Cmakelist?




Attachments:

Please Log in or Create an account to join the conversation.

More
29 Apr 2016 15:54 #2

The dependencies of each example on CMake are generated by the following rule in examples\Glut\CMakeLists.txt:

target_link_libraries (${example} ${CHAI3D_LIBRARIES} ${GLUT_LIBRARIES})
Does the project (13-primitives) build correctly? If that is the case, then the issue is purely in the IDE - Visual Studio can sometimes take a while to index the entire solution to cross-reference the dependencies in the editor (what Microsoft calls IntelliSense), but this is independent of the compilation dependencies. Try and build the entire solution and let me know if compilation fails.

Please Log in or Create an account to join the conversation.

More
03 May 2016 13:46 #3

Firstly thank you for your response

actually I figured out how to link the libraries using Cmake, the problem is that I was using the the wrong CmakeList. I should have used the first cmakelisit that is locate right inside chai3d folder, because this list contains instructions that will direct Cmake to go inside the examples folder to find the sub cmake list that contains the inking rules to link all the example codes, as you can see here:

if (EXISTS ${PROJECT_SOURCE_DIR}/examples)
  add_subdirectory (${PROJECT_SOURCE_DIR}/examples)
endif ()

But now that I solved this problem another separate problem popped up. inside a folder called "Templates"I tried to generate the solution file for source "application.cpp" using the Cmakelist provided by Chai3d, after I generated "application-GLUT.sln" I tried to build it but i got this error:

"The "HasTrailingSlash" function only accepts a scalar value, but its argument "$(OutDir)" evaluates to "C:\Users\robotic\Desktop\New;folder\chai3d-3.1.1\bin\win-x64\" which is not a scalar value. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets:

aside from this error I realized that the build folder which contains the files the Cmake generates appears to have some missing files and folders supposed to be generated by Cmake. as you can see in the picture:




it is clear that a folder called "application-GLUT.dir" is missing ... because I usually see it in all the project that I link using Cmake of course with a different name (the corresponding name of the project).

Attachments:

Please Log in or Create an account to join the conversation.

More
17 May 2016 14:40 #4

I've tried to reproduce the problem, but could not. This is what I've tried on Windows, using CMake 3.4.1 and VS2013 (running CMake from a terminal, assuming that CHAI3D is installed in c:\chai3d-3.1.1), on a out-of-the-box CHAI3D installation:

c:\
cd chai3d-3.1.1
mkdir build
cd build
cmake ..
cmake --build . --config Release
Now that we have built the main CHAI3D library, we can build the template using CMake as well:
c:\
cd chai3d-3.1.1\templates\GLUT
mkdir build
cd build
cmake ..
cmake --build . --config Release
CMake also correctly creates application-GLUT.sln and all related files and folders (including application-GLUT.dir).
Please try and repeat the build using the sequence of commands above. If it still fails, please post your configuration (version of Windows, VisualStudio and CMake) and we will investigate further.

Please Log in or Create an account to join the conversation.

More
15 Jun 2016 15:46 #5

I was shooting a video to show you how it doesn't work, but before that I changed the computer that a usually use by another one. Surprisingly it Worked !!! the template code got successfully linked using cmake. so most probably something in the system was not compatible with cmake linking rules.

any way I shot the video and i would like to share it. thanks a lot for your help.

Please Log in or Create an account to join the conversation.

Powered by Kunena Forum