cmake_minimum_required (VERSION 3.0.0) project (slsqp) include (CheckIncludeFiles) include (CheckFunctionExists) include (CheckTypeSize) include (CheckCCompilerFlag) include (CheckCXXSymbolExists) include (CheckCSourceCompiles) include (CheckCXXCompilerFlag) include (CheckLibraryExists) check_include_file (getopt.h HAVE_GETOPT_H) check_include_file (unistd.h HAVE_UNISTD_H) check_include_file (stdint.h HAVE_STDINT_H) check_include_file (time.h HAVE_TIME_H) check_include_file (sys/time.h HAVE_SYS_TIME_H) if (HAVE_TIME_H AND HAVE_SYS_TIME_H) set (TIME_WITH_SYS_TIME TRUE) endif () check_function_exists (getpid HAVE_GETPID) check_function_exists (syscall HAVE_GETTID_SYSCALL) check_function_exists (isinf HAVE_ISINF) check_function_exists (isnan HAVE_ISNAN) check_function_exists (gettimeofday HAVE_GETTIMEOFDAY) check_function_exists (qsort_r HAVE_QSORT_R) check_function_exists (time HAVE_TIME) check_function_exists (copysign HAVE_COPYSIGN) check_function_exists (getopt HAVE_GETOPT) check_type_size ("uint32_t" SIZEOF_UINT32_T) set (HAVE_UINT32_T ${SIZEOF_UINT32_T}) check_type_size ("unsigned int" SIZEOF_UNSIGNED_INT) check_type_size ("unsigned long" SIZEOF_UNSIGNED_LONG) check_library_exists ("m" sqrt "" HAVE_LIBM) if (HAVE_LIBM) set (M_LIBRARY m) endif() configure_file (${CMAKE_CURRENT_SOURCE_DIR}/nlopt_config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/nlopt_config.h IMMEDIATE) add_library (slsqp slsqp.c) target_include_directories (slsqp PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})