diff --git a/CMakeLists.txt b/CMakeLists.txt index 903c4751104c041861cb26009f54c7b05fbdbfe4..053003dcc22e458968329c0a733172af376007cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -122,6 +122,7 @@ 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) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 74a614817b2ce2e1576e37099240964a217086cc..a1eef415446c16482b13d1cd6e3d1ea57222868d 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -10,8 +10,11 @@ if (CMAKE_HOST_SYSTEM_NAME MATCHES Windows) endif () # have to add timer.c and mt19937ar.c as symbols are declared extern -add_executable (testopt testfuncs.c testfuncs.h testopt.c - ${PROJECT_SOURCE_DIR}/src/util/timer.c ${PROJECT_SOURCE_DIR}/src/util/mt19937ar.c ${PROJECT_SOURCE_DIR}/src/util/nlopt-getopt.c) +set (testopt_sources testfuncs.c testfuncs.h testopt.c ${PROJECT_SOURCE_DIR}/src/util/timer.c ${PROJECT_SOURCE_DIR}/src/util/mt19937ar.c) +if (NOT HAVE_GETOPT OR NOT HAVE_GETOPT_H) + list (APPEND testopt_sources ${PROJECT_SOURCE_DIR}/src/util/nlopt-getopt.c) +endif () +add_executable (testopt ${testopt_sources}) target_link_libraries (testopt ${nlopt_lib}) target_include_directories (testopt PRIVATE ${NLOPT_PRIVATE_INCLUDE_DIRS}) add_dependencies (tests testopt)