diff --git a/CMake/Python.cmake b/CMake/Python.cmake index 1b97fb4..0c0fa24 100644 --- a/CMake/Python.cmake +++ b/CMake/Python.cmake @@ -1,23 +1,9 @@ -# Check if Python vars have been set in CLI - -message(STATUS "Checking if Python paths have been set...") - -if (NOT DEFINED PYTHON_INCLUDE_DIR) - message(FATAL_ERROR "Please provide Python include directory as CMake argument! Usage: -DPYTHON_INCLUDE_DIR=/path/to/python/include") -else() - message(STATUS "PYTHON_INCLUDE_DIR=${PYTHON_INCLUDE_DIR}") -endif() - -if (NOT DEFINED PYTHON_LIB_DIR) - message(FATAL_ERROR "Please provide Python lib directory as CMake argument! Usage: -DPYTHON_LIB_DIR=/path/to/python/lib") -else() - message(STATUS "PYTHON_LIB_DIR=${PYTHON_LIB_DIR}") -endif() - -if (NOT DEFINED PYTHON_LIB) - message(FATAL_ERROR "Please provide Python library as CMake argument! Usage -DPYTHON_LIB=python3.11") -else() - message(STATUS "PYTHON_LIB=${PYTHON_LIB}") -endif() - -message(STATUS "Python OK!") \ No newline at end of file +# Check if Python environment variables have been set + +find_package(Python3 COMPONENTS Interpreter Development) + +if (NOT DEFINED Python3_Development_FOUND) + message(FATAL_ERROR "Please make sure Python3 (including development artifacts) installed correctly on your system!") +else() + message(STATUS "Linking Python ${Python3_VERSION}") +endif() \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 1245de6..99ae765 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,13 +5,13 @@ set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}) set(EXTERN_DIR ${ROOT_DIR}/Extern) set(SCRIPTS_DIR ${ROOT_DIR}/CMake) set(SAMPLE_PLUGINS_DIR ${ROOT_DIR}/Samples) -include("${SCRIPTS_DIR}/Python.cmake") set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED true) project(Source2Py LANGUAGES CXX) +include("${SCRIPTS_DIR}/Python.cmake") include("${SCRIPTS_DIR}/Source2SDK.cmake") include("${SCRIPTS_DIR}/Metamod.cmake") @@ -25,15 +25,12 @@ target_include_directories(Source2Py PRIVATE ${SOURCE2SDK_INCLUDE_DIRS} ${METAMOD_INCLUDE_DIRS} ${EXTERN_DIR}/pybind11/include - ${PYTHON_INCLUDE_DIR} -) -target_link_directories(Source2Py PRIVATE - ${PYTHON_LIB_DIR} + ${Python3_INCLUDE_DIRS} ) target_link_libraries(Source2Py PRIVATE Source2SDK Metamod - ${PYTHON_LIB} + ${Python3_LIBRARIES} ) set_target_properties(Source2Py PROPERTIES OUTPUT_NAME "Source2Py"