From 5c947828767c9140b2e5cd7cbf524064f7941530 Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Tue, 10 May 2022 22:08:01 -0700 Subject: [PATCH] Remove debug wrapper, now that I know how to use a debug python build --- CMakeLists.txt | 31 ++++++------------------------- setup.py | 4 +++- tests/run_tests.cpp | 44 -------------------------------------------- 3 files changed, 9 insertions(+), 70 deletions(-) delete mode 100644 tests/run_tests.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f26a43..ba125f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,18 +1,11 @@ cmake_minimum_required(VERSION 3.18) -include(CheckIPOSupported) include(tools/CompilerWarnings.cmake) +set(CMAKE_VERBOSE_MAKEFILE ON) project(quicktex) # Find dependencies -if (DEFINED QUICKTEX_MODULE_ONLY) - # Not all python installs include the headers necessary for embedding. If we are only building the module, - # we can ignore the embed headers - find_package(Python COMPONENTS Interpreter Development.Module) -else () - find_package(Python COMPONENTS Interpreter Development) -endif () - +find_package(Python COMPONENTS Interpreter Development.Module) find_package(pybind11 CONFIG REQUIRED) find_package(OpenMP) @@ -37,8 +30,6 @@ file(GLOB HEADER_FILES "quicktex/s3tc/interpolator/*.h" ) -file(GLOB TEST_FILES "tests/*.cpp") - file(GLOB_RECURSE PYTHON_FILES "src/**/*.py") # Organize source files together for some IDEs @@ -49,34 +40,24 @@ pybind11_add_module(_quicktex ${SOURCE_FILES} ${HEADER_FILES}) -add_executable(test_quicktex - ${SOURCE_FILES} - ${HEADER_FILES} - ${TEST_FILES}) - -target_link_libraries(test_quicktex PRIVATE pybind11::embed) - -target_compile_definitions(test_quicktex PRIVATE -DCUSTOM_SYS_PATH="${CMAKE_HOME_DIRECTORY}/env/lib/python3.9/site-packages") +# Set Quicktex version info target_compile_definitions(_quicktex PRIVATE VERSION_INFO=${QUICKTEX_VERSION_INFO}) # enable openMP if available if (OpenMP_CXX_FOUND) target_link_libraries(_quicktex PUBLIC OpenMP::OpenMP_CXX) - target_link_libraries(test_quicktex PUBLIC OpenMP::OpenMP_CXX) endif () # Set module features, like C/C++ standards target_compile_features(_quicktex PUBLIC cxx_std_17 c_std_11) -target_compile_features(test_quicktex PUBLIC cxx_std_17 c_std_11) +# Set compiler warnings set_project_warnings(_quicktex) -set_project_warnings(test_quicktex) - -set(CMAKE_VERBOSE_MAKEFILE ON) +# Clang-specific if (CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++abi") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -stdlib=libc++ -fsanitize=undefined") set(PROJECT_WARNINGS ${CLANG_WARNINGS}) endif () diff --git a/setup.py b/setup.py index b5d9f98..eafe2ad 100644 --- a/setup.py +++ b/setup.py @@ -31,7 +31,9 @@ class CMakeBuild(build_ext): if not extdir.endswith(os.path.sep): extdir += os.path.sep - cfg = "Debug" if self.debug else "Release" + cfg = "Debug" if self.debug else "RelWithDebInfo" + if 'QUICKTEX_DEBUG' in os.environ: + cfg = "Debug" # CMake lets you override the generator - we need to check this. # Can be set with Conda-Build, for example. diff --git a/tests/run_tests.cpp b/tests/run_tests.cpp deleted file mode 100644 index c78d5ad..0000000 --- a/tests/run_tests.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* Quicktex Texture Compression Library - Copyright (C) 2021 Andrew Cassidy - Partially derived from rgbcx.h written by Richard Geldreich - and licenced under the public domain - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . - */ - -// This file allows for easy debugging in CLion or other IDEs that dont natively support cross-debugging between Python and C++ - -#include - -#include -#include - -namespace py = pybind11; -using namespace pybind11::literals; - -#define STRINGIFY(x) #x -#define MACRO_STRINGIFY(x) STRINGIFY(x) - -int main() { - py::scoped_interpreter guard{}; - - py::module_ site = py::module_::import("site"); - - site.attr("addsitedir")(CUSTOM_SYS_PATH); - - py::module_ nose = py::module_::import("nose"); - py::module_ tests = py::module_::import("tests"); - py::list argv(1); - nose.attr("runmodule")("name"_a = "tests.test_bc1", "exit"_a = false); -} \ No newline at end of file