From 101502c4385844a16daff3beac83cb9e32dadb7e Mon Sep 17 00:00:00 2001 From: wilwal23 <67158459+wilwal23@users.noreply.github.com> Date: Sun, 17 Jul 2022 12:52:03 +0200 Subject: [PATCH] Update CMakeLists.txt Issue #25 solved. Added if at line 45, based on this question: https://stackoverflow.com/questions/2274006/cmake-invalid-numeric-argument-wextra After that, a new error popped up concerning "m.lib" file not found. Removed "m" at line 61, based on this question: https://stackoverflow.com/questions/19333898/lnk1181-cannot-open-input-file-m-lib Now the project can be built successfully and the example runs correctly. PS: I'm not a computer scientist so I do not assure what I did is wrong, consider this pull request as a hint to solve Issue #25. --- CMakeLists.txt | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 615261b..990abf9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,10 +41,14 @@ set( CMAKE_VISIBILITY_INLINES_HIDDEN 1) set( CMAKE_POLICY_DEFAULT_CMP0079 NEW) set( CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) set( CMAKE_INCLUDE_CURRENT_DIR TRUE) - -set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic -Wunused-macros") -set( CMAKE_C_FLAGS_DEBUG "-O0 -g -Wall -Wno-unused-command-line-argument") -set( CMAKE_C_FLAGS_RELEASE "-O3 -Werror -Wno-unused-command-line-argument") + +# Set default compile flags for GCC +if(CMAKE_COMPILER_IS_GNUC) + message(STATUS "GCC detected, adding compile flags") + set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic -Wunused-macros") + set( CMAKE_C_FLAGS_DEBUG "-O0 -g -Wall -Wno-unused-command-line-argument") + set( CMAKE_C_FLAGS_RELEASE "-O3 -Werror -Wno-unused-command-line-argument") +endif(CMAKE_COMPILER_IS_GNUC) set( GK_PUBLIC_HEADER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) @@ -54,7 +58,7 @@ add_library(${PROJECT_NAME} ${GK_PUBLIC_HEADER_DIR}/openGJK/openGJK.h ) -target_link_libraries(${PROJECT_NAME} m) +target_link_libraries(${PROJECT_NAME}) target_include_directories( ${PROJECT_NAME} @@ -83,4 +87,4 @@ endif (UNIX) # Wrap up feedback on setup message(STATUS "Version : " ${CMAKE_PROJECT_VERSION} ) -message(STATUS "Build type : " ${CMAKE_BUILD_TYPE} ) \ No newline at end of file +message(STATUS "Build type : " ${CMAKE_BUILD_TYPE} )