Skip to content

How in include Physx in a cmake project #249

@arijeetbaruah

Description

@arijeetbaruah

I am using PhysX and cmake to make a game for my university project. However, I am having issues with cmake library. My PhysX code is added as a git submodule within my project in submodules directory

cmake_minimum_required(VERSION 3.14)
## Giving a name to the project
project(weird_golf_game)

#Setup CMake to run tests
enable_testing()

## Including headers, from both the current project and from the imported libraries
include_directories(include)
...
include_directories(submodules/PhysX/physx/include)
add_subdirectory(submodules/PhysX/physx/compiler/public)

## I want to use the C++17 standard, forsooth!
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# OpenGL
find_package(OpenGL REQUIRED)

add_executable(weird_golf_game ...)
target_link_libraries(weird_golf_game ... opengl32 PhysX)

but on running cmake I am getting these error:

PHYSX ROOT D:/Source/Repos/weird-golf-game/submodules/PhysX/physx
PhysX Build Platform: 
Using CXX Compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64/cl.exe
CMake Error at submodules/PhysX/externals/cmakemodules/NvidiaBuildOptions.cmake:48 (MESSAGE):
  When using the GameWorks output structure you must specify
  PX_OUTPUT_LIB_DIR as the base
Call Stack (most recent call first):
  submodules/PhysX/physx/source/compiler/cmake/CMakeLists.txt:70 (INCLUDE)


Configuring incomplete, errors occurred!
See also "D:/Source/Repos/weird-golf-game/out/CMakeFiles/CMakeOutput.log".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions