From d8b05d12d52ba390b1b8dceca784f35a13f42934 Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin <15944199+nekonomicon@users.noreply.github.com> Date: Thu, 16 Jun 2022 11:54:55 +0500 Subject: [PATCH] cmake: better tgmath.h check. --- CMakeLists.txt | 11 +++++++++++ cl_dll/CMakeLists.txt | 6 ------ dlls/CMakeLists.txt | 6 ------ 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 123cd838..0a8c657c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,8 @@ endif() # Install custom module path set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/") +include(CheckIncludeFile) +include(CheckCSourceCompiles) include(VSForceXPToolchain) # Force XP toolchain for Visual Studio project (HLSDK-XASH3D) @@ -111,6 +113,15 @@ else() add_definitions(-D_CRT_SILENCE_NONCONFORMING_TGMATH_H) endif() +check_include_file("tgmath.h" HAVE_TGMATH_H) +if(HAVE_TGMATH_H) + check_c_source_compiles("#include + const float val = 2, val2 = 3; + int main(){ return (int)(-asin(val) + cos(val2));" HAVE_VALID_TGMATH_H ) + if(${HAVE_VALID_TGMATH_H}) + add_definitions(-DHAVE_TGMATH_H) + endif() +endif() if(BUILD_CLIENT) add_subdirectory(cl_dll) diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index 0869467d..ae4a47cc 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -25,12 +25,6 @@ project (CLDLL) set (CLDLL_LIBRARY client) -include(CheckIncludeFile) -check_include_file("tgmath.h" HAVE_TGMATH_H) -if(HAVE_TGMATH_H) - add_definitions(-DHAVE_TGMATH_H) -endif() - add_definitions(-DCLIENT_WEAPONS -DCLIENT_DLL) if(NOT MSVC) diff --git a/dlls/CMakeLists.txt b/dlls/CMakeLists.txt index 77cd47e6..ba828008 100644 --- a/dlls/CMakeLists.txt +++ b/dlls/CMakeLists.txt @@ -25,12 +25,6 @@ project (SVDLL) set (SVDLL_LIBRARY server) -include(CheckIncludeFile) -check_include_file("tgmath.h" HAVE_TGMATH_H) -if(HAVE_TGMATH_H) - add_definitions(-DHAVE_TGMATH_H) -endif() - add_definitions(-DCLIENT_WEAPONS) if(NOT MSVC)