Environment: wsl22.04
gcc11.4
make 4.21
(the clion project uses the wsl.exe as terminal, and Toolchains are all in wsl22.04.)
This is my CMakeLists.txt
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
project(sdfibm LANGUAGES CXX C)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG")
if(DEFINED ENV{WM_PROJECT_DIR})
MESSAGE(STATUS "OpenFOAM: " $ENV{WM_PROJECT_DIR})
else()
message(FATAL_ERROR "Cannot find OpenFOAM")
endif(DEFINED ENV{WM_PROJECT_DIR})
And then error is:
CMake Error at CMakeLists.txt:11 (message): Cannot find OpenFOAM
But I run echo $WM_PROJECT_DIR
in the terminal of clion.
The result is /opt/openfoam9
try1: I had try to reload the cache file, but it made no differences.
try2: I add ‘set(ENV{WM_PROJECT_DIR} /opt/openfoam9)’ before if(DEFINE ENV{WM_PROJECT_DIR})
, it didn’t find error.
So why the environment variable is null in CMakeLists.txt, but it’s right in CommandLine.
xieyouchen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.