Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't compile on Windows with Code::Blocks without modifying CMakeLists.txt by hand #528

Closed
jd-imi opened this issue Nov 6, 2023 · 3 comments · Fixed by #533
Closed
Assignees

Comments

@jd-imi
Copy link
Contributor

jd-imi commented Nov 6, 2023

If I try to follow instructions in README.md, i.e.:

c:\> mkdir build
c:\> cd build/
c:\> cmake .. -G"CodeBlocks - MinGW Makefiles"

I get :

C:\PROGRA~1\MINGW-~1\X86_64~1.0-P\mingw64\bin\gcc.exe -DBACDL_BIP -DBACNET_PROPERTY_LISTS -DBACNET_PROTOCOL_REVISION=19 -DBACNET_STACK_DEPRECATED_DISABLE -DBACNET_STACK_STATIC_DEFINE -DBAC_ROUTING -DPRINT_ENABLED=1 @CMakeFiles/bacnet-stack.dir/includes_C.rsp -O3 -DNDEBUG   /W3 /D_CRT_SECURE_NO_WARNINGS /wd4244 /wd4018 /wd4267 -o CMakeFiles\bacnet-stack.dir\src\bacnet\abort.c.obj -c D:\Documents\dev\BACnet_Stack_original_repo\bacnet-stack\src\bacnet\abort.c
gcc.exe: error: /W3: No such file or directory
gcc.exe: error: /D_CRT_SECURE_NO_WARNINGS: No such file or directory
gcc.exe: error: /wd4244: No such file or directory
gcc.exe: error: /wd4018: No such file or directory
gcc.exe: error: /wd4267: No such file or directory

If I apply this modification:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4b9307dc..3676bcfa 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -538,7 +538,7 @@ elseif(WIN32)
     $<$<BOOL:${BACDL_BIP}>:ws2_32>
     $<$<BOOL:${BACDL_BIP}>:iphlpapi>)

-  add_definitions("/W3 /D_CRT_SECURE_NO_WARNINGS /wd4244 /wd4018 /wd4267")
+  #add_definitions("/W3 /D_CRT_SECURE_NO_WARNINGS /wd4244 /wd4018 /wd4267")

   target_sources(${PROJECT_NAME} PRIVATE
     ports/win32/bacport.h

It works

@skarg
Copy link
Collaborator

skarg commented Nov 12, 2023

Researching methods to detect specific compilers:

The problem line is MSVC specific, so we should wrap a check around that:

if(MSVC)
    add_definitions("/W3 /D_CRT_SECURE_NO_WARNINGS /wd4244 /wd4018 /wd4267")
endif()

Does that work for you?

@jd-imi
Copy link
Contributor Author

jd-imi commented Nov 13, 2023

It is working well with the change you proposed.

@skarg skarg self-assigned this Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants