35 lines
846 B
CMake
Raw Normal View History

2019-11-11 23:01:05 +01:00
add_library(MathFunctions mysqrt.cxx)
2019-11-11 23:01:05 +01:00
# state that anybody linking to us needs to include the current source dir
# to find MathFunctions.h, while we don't.
target_include_directories(MathFunctions
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
)
2020-02-01 23:06:01 +01:00
# does this system provide the log and exp functions?
2022-07-29 21:54:54 +02:00
include(CheckCXXSourceCompiles)
check_cxx_source_compiles("
#include <cmath>
int main() {
std::log(1.0);
return 0;
}
" HAVE_LOG)
check_cxx_source_compiles("
#include <cmath>
int main() {
std::exp(1.0);
return 0;
}
" HAVE_EXP)
2020-02-01 23:06:01 +01:00
2020-08-30 11:54:41 +02:00
# add compile definitions
2020-02-01 23:06:01 +01:00
if(HAVE_LOG AND HAVE_EXP)
target_compile_definitions(MathFunctions
PRIVATE "HAVE_LOG" "HAVE_EXP")
endif()
# install rules
2019-11-11 23:01:05 +01:00
install(TARGETS MathFunctions DESTINATION lib)
install(FILES MathFunctions.h DESTINATION include)