I have already successfully installed OpenSim in Ubuntu 20.04. I know it works because all tests passed, and I can import OpenSim in python files and use functions (when I create the environment variable: export OPENSIM_HOME=~/opensim/install/lib ).
However, I am having some trouble importing the library in CPP files.
In a CmakeLists file, I set the environment variables, append the CMAKE_MODULE_PATH for finding OpenSim, try to find OpenSim, include directories, and add the subdirectory src:
Code: Select all
project(test)
cmake_minimum_required(VERSION 3.2.0)
# Settings.
# ---------
set( ENV{OPENSIM_HOME} /home/ana/opensim/install/include )
set( ENV{OPENSIM_INCLUDE_DIR} /home/ana/opensim/install/include )
set( ENV{OPENSIM_INSTALL_DIR} /home/ana/opensim/install/include )
message(STATUS "OPENSIM_HOME: $ENV{OPENSIM_HOME}")
message(STATUS "OPENSIM_INSTALL_DIR: $ENV{OPENSIM_INSTALL_DIR}")
message(STATUS "OPENSIM_INCLUDE_DIR: $ENV{OPENSIM_INCLUDE_DIR}")
message(STATUS "CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}")
# Find and hook up to OpenSim.
# ----------------------------
find_package(OpenSim REQUIRED)
include_directories(${OPENSIMSIMBODY_INCLUDE_DIRS})
# Add source code.
# ----------------------------
add_subdirectory(src)
However, when I try to actually build the project, it gives back: fatal error: OpenSim.h: No such file or directory.
In FindOpenSim. cmake also says that OPENSIM_INSTALL_DIR has the highest priority in finding the path, but it only works when I change OPENSIM_HOME. Moreover, if I build it after it says it found OpenSim, it gives the message saying it didn't. So, I got the feeling that I am doing something really wrong here.
I appreciate any help.