
* Clean up the CMake build system and improve the FindFFTW3 module. * Fixes for Linux build * Include winsock.h to get struct timeval * Couple more fixes for MSVC, also add new FindMath module * Update host build README for new CMake changes (esp. Windows) * Try to fix Travis OS X build error * Add docs about pthread-win32 * Whoops, AppVeyor caught a bug in FindFFTW where the includes not being found weren't generating a fatal error. * Travis rebuild bump * One more fix: replace hardcoded include paths with a PATH_SUFFIX to standard include paths * Invert Windows preprocessor flag so it's only needed when using a static build. This preserves compatibility with the previous system. * Fix copy-paste error * Update cmake modules from amber-cmake upstream, incorporate TryLinkLibrary into FindUSB1 * Fix missing include
92 lines
2.1 KiB
CMake
92 lines
2.1 KiB
CMake
#[=======================================================================[.rst:
|
|
FindCMath
|
|
-------
|
|
|
|
Finds the C Math library.
|
|
|
|
Imported Targets
|
|
^^^^^^^^^^^^^^^^
|
|
|
|
This module provides the following imported targets, if found:
|
|
|
|
``C::Math``
|
|
The C math library
|
|
|
|
Result Variables
|
|
^^^^^^^^^^^^^^^^
|
|
|
|
This will define the following variables:
|
|
|
|
``CMath_FOUND``
|
|
True if the system has the C math library.
|
|
|
|
``CMath_LIBRARIES``
|
|
List of C math libraries. Might be empty.
|
|
|
|
#]=======================================================================]
|
|
|
|
include(CMakePushCheckState)
|
|
include(CheckCSourceCompiles)
|
|
|
|
set(CHECK_SINE_C_SOURCE "#include <math.h>
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
return sin(argc - 1);
|
|
}")
|
|
|
|
set(CMath_WORKS FALSE)
|
|
|
|
check_c_source_compiles("${CHECK_SINE_C_SOURCE}" CMath_LINKS_WITHOUT_M)
|
|
|
|
if ("${CMath_LINKS_WITHOUT_M}")
|
|
set(CMath_LIBRARIES "")
|
|
else()
|
|
find_library(CMath_LIBRARIES NAMES m math libm)
|
|
|
|
if(EXISTS "${CMath_LIBRARIES}")
|
|
cmake_push_check_state()
|
|
set(CMAKE_REQUIRED_FLAGS "")
|
|
set(CMAKE_REQUIRED_LIBRARIES "${CMath_LIBRARIES}")
|
|
check_c_source_compiles("${CHECK_SINE_C_SOURCE}" CMath_LINKS_WITH_M)
|
|
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE_CMATH})
|
|
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE_CMATH})
|
|
cmake_pop_check_state()
|
|
else()
|
|
set(CMath_LINKS_WITH_M FALSE)
|
|
endif()
|
|
endif ()
|
|
|
|
if (("${CMath_LINKS_WITH_M}" OR "${CMath_LINKS_WITHOUT_M}") )
|
|
set(CMath_WORKS TRUE)
|
|
endif()
|
|
|
|
# we want FPHSA to print a library path when libm is found as a library
|
|
if(CMath_LINKS_WITH_M)
|
|
set(CMath_REQUIRED_VARS CMath_LIBRARIES CMath_WORKS)
|
|
else()
|
|
set(CMath_REQUIRED_VARS CMath_WORKS)
|
|
endif()
|
|
|
|
include(FindPackageHandleStandardArgs)
|
|
find_package_handle_standard_args(CMath DEFAULT_MSG ${CMath_REQUIRED_VARS})
|
|
|
|
if ("${CMath_FOUND}" AND NOT TARGET C::Math)
|
|
|
|
if(CMath_LINKS_WITH_M)
|
|
# create imported target
|
|
import_library(C::Math "${CMath_LIBRARIES}")
|
|
else()
|
|
# create empty target
|
|
add_library(C::Math INTERFACE IMPORTED GLOBAL)
|
|
endif()
|
|
|
|
endif ()
|
|
|
|
|
|
# Mark variables as advanced, effectively hiding from ccmake interface
|
|
mark_as_advanced(
|
|
CMath_LINKS_WITHOUT_M
|
|
CMath_LINKS_WITH_M
|
|
CMath_LIBRARIES
|
|
) |