mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Link with libm.so on those platforms that require it.
This commit is contained in:
parent
43749a9495
commit
4ee573e23a
@ -1,7 +1,7 @@
|
||||
|
||||
set(cmake_FILES
|
||||
GncAddGSchemaTargets.cmake GncAddSchemeTargets.cmake
|
||||
GncAddSwigCommand.cmake GncAddTest.cmake
|
||||
GncAddSwigCommand.cmake GncAddTest.cmake GncFindLibm.cmake
|
||||
MacroAddSourceFileCompileFlags.cmake MacroAppendForeach.cmake
|
||||
MakeDist.cmake MakeDistFiles.cmake MakeDistCheck.cmake
|
||||
)
|
||||
|
46
common/cmake_modules/GncFindLibm.cmake
Normal file
46
common/cmake_modules/GncFindLibm.cmake
Normal file
@ -0,0 +1,46 @@
|
||||
# Copied & modified from https://android.googlesource.com/platform/external/eigen/+/master/cmake/FindStandardMathLibrary.cmake
|
||||
# Copyright (c) 2010 Benoit Jacob <jacob.benoit.1@gmail.com>
|
||||
# Redistribution and use is allowed according to the terms of the 2-clause BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
|
||||
#Detect whether this platform requires libm for pow().
|
||||
|
||||
include(CheckCXXSourceCompiles)
|
||||
macro (gnc_check_standard_math_library)
|
||||
set(find_standard_math_library_test_program
|
||||
"
|
||||
#include <math.h>
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
double foo = pow(2.0, 2.0);
|
||||
return foo == 4.0;
|
||||
}"
|
||||
)
|
||||
|
||||
set(CMAKE_REQUIRED_FLAGS "")
|
||||
set(CMAKE_REQUIRED_LIBRARIES "")
|
||||
check_c_source_compiles(
|
||||
"${find_standard_math_library_test_program}"
|
||||
standard_math_library_linked_to_automatically
|
||||
)
|
||||
if(standard_math_library_linked_to_automatically)
|
||||
# the test program linked successfully without any linker flag.
|
||||
set(STANDARD_MATH_LIBRARY "")
|
||||
set(STANDARD_MATH_LIBRARY_FOUND TRUE)
|
||||
else()
|
||||
# the test program did not link successfully without any linker flag.
|
||||
# Try again with standard name 'm' for the standard math library.
|
||||
set(CMAKE_REQUIRED_LIBRARIES "m")
|
||||
check_c_source_compiles(
|
||||
"${find_standard_math_library_test_program}"
|
||||
standard_math_library_linked_to_as_m)
|
||||
if(standard_math_library_linked_to_as_m)
|
||||
# the test program linked successfully when linking to the 'm' library
|
||||
set(STANDARD_MATH_LIBRARY "m")
|
||||
set(STANDARD_MATH_LIBRARY_FOUND TRUE)
|
||||
else()
|
||||
# the test program still doesn't link successfully
|
||||
set(STANDARD_MATH_LIBRARY_FOUND FALSE)
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
@ -1,6 +1,9 @@
|
||||
# NB: Unit tests which require GSchemas should be made conditional on COMPILE_GSCHEMAS.
|
||||
add_subdirectory(test)
|
||||
add_subdirectory(mocks)
|
||||
|
||||
include (GncFindLibm)
|
||||
|
||||
# Build the library
|
||||
|
||||
set (app_utils_noinst_HEADERS
|
||||
@ -67,10 +70,15 @@ set (app_utils_SOURCES
|
||||
gnc-ui-util.c
|
||||
gnc-ui-balances.c
|
||||
option-util.c
|
||||
)
|
||||
)
|
||||
|
||||
set_source_files_properties (${app_utils_SOURCES} PROPERTIES OBJECT_DEPENDS ${CONFIG_H})
|
||||
|
||||
gnc_check_standard_math_library()
|
||||
if (NOT STANDARD_MATH_LIBRARY_FOUND)
|
||||
message(FATAL_ERROR "An implementation of the standard C function pow() is required and is supported neither by the C runtime nor libm.so.")
|
||||
endif()
|
||||
|
||||
set(app_utils_ALL_SOURCES ${app_utils_SOURCES} ${app_utils_HEADERS} ${app_utils_noinst_HEADERS})
|
||||
set(app_utils_ALL_LIBRARIES
|
||||
gnc-engine
|
||||
@ -78,7 +86,10 @@ set(app_utils_ALL_LIBRARIES
|
||||
gnucash-guile
|
||||
${GIO_LDFLAGS}
|
||||
${LIBXML2_LDFLAGS}
|
||||
${LIBXSLT_LDFLAGS})
|
||||
${LIBXSLT_LDFLAGS}
|
||||
${STANDARD_MATH_LIBRARY}
|
||||
)
|
||||
|
||||
set(app_utils_ALL_INCLUDES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/calculation
|
||||
${GIO_INCLUDE_DIRS}
|
||||
|
Loading…
Reference in New Issue
Block a user