dvidelabs / flatcc

FlatBuffers Compiler and Library in C for C
Apache License 2.0
646 stars 182 forks source link

Cannot build under Centos 7 #137

Closed krbvroc1 closed 4 years ago

krbvroc1 commented 4 years ago

Brand new user here.

I am a Centos 7 user. I downloaded and ran './scripts/initbuild.sh make'

-- The C compiler identification is GNU 4.8.5
-- The CXX compiler identification is GNU 4.8.5
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- dist install dir /home/kbass/flatcc
-- lib install dir /home/kbass/flatcc/lib
-- Setting GNU C compiler options with c11 and Posix
CMake Error at CMakeLists.txt:213 (if):
  if given arguments:

    "GCC_VERSION" "VERSION_GREATER_EQUAL" "8.0"

  Unknown arguments specified

-- Configuring incomplete, errors occurred!
mikkelfj commented 4 years ago

There is a specific check in the flatcc CMakeList.txt file at line 213 to see if the gcc version is 8.0 or larger. This is because gcc is being obnoxious with warnings as errors that hurt source interoperability with other compilers. This change in CMakeLists.txt is relatively new and probably hasn't been tested with Centos.

I don't know why it fails. Perhaps the CMake version installed does not like the syntax, as suggested by the error code. Unfortunately I'm not an expert on CMake so I can't say why that would be. If you can come up with a fix, I'm open to adopting it. If Centos is running an older gcc, you can try to disable the offending branch in the CMakeList file.

mikkelfj commented 4 years ago

Based on

https://stackoverflow.com/questions/16667017/cmake-express-the-greater-or-equal-statement#16668344

I think VERSION_GREATER_EQUAL was introduced in CMake 3.7 and you probably don't have that.

But it seems that VERSION_LESS is supported in your version since it has executed earlier:

https://github.com/dvidelabs/flatcc/blob/5d929cc916f2ae84c7232a4444e3e3ee3161814e/CMakeLists.txt#L196

So if you can change line 213 into a NOT VERSION_LESS somehow, it might work.

https://github.com/dvidelabs/flatcc/blob/5d929cc916f2ae84c7232a4444e3e3ee3161814e/CMakeLists.txt#L213

Perhaps if (NOT (GCC_VERSION VERSION_LESS 8.0)) ?

krbvroc1 commented 4 years ago

After a quick google search, it appears the VERSION_GREATER_EQUAL operation is not available until a newer verison of cmake (which isn't avail on Centos 7). I see you found that same info while I was typing this.

Yes, changing the line 213 to: if (NOT GCC_VERSION VERSION_LESS 8.0)

does solve the issue.

[EDIT: Centos 7 comes with cmake 2.8.12]

mikkelfj commented 4 years ago

Commited change. Please confirm master branch works for you.

I will not update the CHANGELOG since this was introduced after the last release.

krbvroc1 commented 4 years ago

@mikkelfj I refetched master and it compiles now. Thanks for the quick check in.

mikkelfj commented 4 years ago

You are welcome!