noloader / cryptopp-cmake

CMake files for Crypto++ project
BSD 3-Clause "New" or "Revised" License
92 stars 68 forks source link

CMake fails to run on Ubuntu 14.04 #101

Closed noloader closed 2 years ago

noloader commented 2 years ago

Testing the latest Cmake files shows it fails to run on Ubuntu 14.04. Ubuntu 14.04 is a LTS release with Extended Support. Canonical provides support for Ubuntu 14 until 2024. It is a ESM.

The error is:

CMake Error at CMakeLists.txt:11 (cmake_minimum_required):
  CMake 3.1 or higher is required.  You are running version 2.8.12.2

Here's a screen capture of the SSH session and the test script:

cmake-fail

Please be mindful of our Cmake requirements.

abdes commented 2 years ago

Is it 32 bit or 64 bit OS?

Vollstrecker commented 2 years ago

You're talking about an 8 year old release. Yes, ist's always good ti stay compatible with older stuff, but as I Said before, compiling cryptopp ist not for fun. It's usually to Compiler other Software with it. So if a User want's to stay in such an old distro, but want's also to User Software which requires a that new version of the lib, why shouldn't this rare User bei able to compile a little more recent version of cmake.

Imho the Policy Here should bei changed to support the 2 latest ltd releases so everyone with a need of long Support has plenty of time.

abdes commented 2 years ago

Just made a VM and tested the tag before I make any change to the project:

abdessattar@ubuntu:~/projects/cryptopp$ uname -a
Linux ubuntu 4.4.0-142-generic #168~14.04.1-Ubuntu SMP Sat Jan 19 11:26:28 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
abdessattar@ubuntu:~/projects/cryptopp$ git status
HEAD detached at CRYPTOPP_8_7_0
Untracked files:
  (use "git add <file>..." to include in what will be committed)

    CMakeLists.txt
    cryptopp-config.cmake

nothing added to commit but untracked files present (use "git add" to track)
abdessattar@ubuntu:~/projects/cryptopp$ cd ../cryptopp-cmake/
abdessattar@ubuntu:~/projects/cryptopp-cmake$ git status
HEAD detached at 50f5e59
nothing to commit, working directory clean
abdessattar@ubuntu:~/projects/cryptopp-cmake$ git log -n 1
commit 50f5e5945709a11f555cd52361781a3a6a428453
Author: Jeffrey Walton <noloader@gmail.com>
Date:   Tue Mar 29 22:47:43 2022 -0400

    Rename PowerPC specific files
    This will allow us to filter-out some files more easily. Also see https://github.com/weidai11/cryptopp/commit/48377c
abdessattar@ubuntu:~/projects/cryptopp-cmake$ 

Run cmake...

abdessattar@ubuntu:~/projects/cryptopp-cmake$ cd ../cryptopp
abdessattar@ubuntu:~/projects/cryptopp$ cd build/
abdessattar@ubuntu:~/projects/cryptopp/build$ cmake ..
-- *************************************************************************
The Crypto++ library does not officially support CMake. CMake support is a
community effort, and the library works with the folks using CMake to help
improve it. If you find an issue then please fix it or report it at
https://github.com/noloader/cryptopp-cmake.
-- *************************************************************************
-- CMake version 2.8.12.2
-- System 
-- Processor 
-- Performing Test CRYPTOPP_X86_SSE2
-- Performing Test CRYPTOPP_X86_SSE2 - Success
-- Performing Test CRYPTOPP_X86_SSSE3
-- Performing Test CRYPTOPP_X86_SSSE3 - Success
-- Performing Test CRYPTOPP_X86_SSE41
-- Performing Test CRYPTOPP_X86_SSE41 - Success
-- Performing Test CRYPTOPP_X86_SSE42
-- Performing Test CRYPTOPP_X86_SSE42 - Success
-- Performing Test CRYPTOPP_X86_CLMUL
-- Performing Test CRYPTOPP_X86_CLMUL - Success
-- Performing Test CRYPTOPP_X86_AES
-- Performing Test CRYPTOPP_X86_AES - Success
-- Performing Test CRYPTOPP_X86_AVX
-- Performing Test CRYPTOPP_X86_AVX - Success
-- Performing Test CRYPTOPP_X86_AVX2
-- Performing Test CRYPTOPP_X86_AVX2 - Success
-- Performing Test CRYPTOPP_X86_SHA
-- Performing Test CRYPTOPP_X86_SHA - Failed
-- Performing Test CRYPTOPP_MIXED_ASM
-- Performing Test CRYPTOPP_MIXED_ASM - Success
-- Platform: x86_64
-- Compiler: /usr/bin/c++
-- Compiler definitions:  CRYPTOPP_DATA_DIR=/home/abdessattar/projects/cryptopp/TestData;-DCRYPTOPP_DISABLE_SHANI
-- Compiler options:  
-- Build type: RelWithDebInfo
-- Configuring done
-- Generating done
-- Build files have been written to: /home/abdessattar/projects/cryptopp/build

It looks fine...

Now run the build...

abdessattar@ubuntu:~/projects/cryptopp/build$ make
Scanning dependencies of target cryptopp-object
[  1%] Building CXX object CMakeFiles/cryptopp-object.dir/cryptlib.cpp.o
c++: error: CRYPTOPP_DATA_DIR=/home/abdessattar/projects/cryptopp/TestData: No such file or directory
make[2]: *** [CMakeFiles/cryptopp-object.dir/cryptlib.cpp.o] Error 1
make[1]: *** [CMakeFiles/cryptopp-object.dir/all] Error 2
make: *** [all] Error 2

This is just one problem. The CMakeLists.txt uses so many features of later versions of CMake, such automatically adding -D to compiler definitions (the code is so inconsistent inside the CMakeLists.txt and still needs to clean that up), and the generators (used for MSVC build) that are only available in later versions, and cmake variables that are only added in later versions, and arguments to cmake functions only available in later versions,...

Now here is another view:

abdessattar@ubuntu:~$ wget https://github.com/Kitware/CMake/releases/download/v3.24.1/cmake-3.24.1-linux-x86_64.sh
abdessattar@ubuntu:~$ ./cmake-3.24.1-linux-x86_64.sh 
abdessattar@ubuntu:~$ ./cmake-3.24.1-linux-x86_64/bin/cmake --version
cmake version 3.24.1
abdessattar@ubuntu:~$ cd projects/cryptopp-cmake/
abdessattar@ubuntu:~/projects/cryptopp-cmake$ git checkout master
Already on 'master'
Your branch is up-to-date with 'origin/master'.
abdessattar@ubuntu:~/projects/cryptopp-cmake$ cd build/
abdessattar@ubuntu:~/projects/cryptopp-cmake/build$ ~/cmake-3.24.1-linux-x86_64/bin/cmake .. -DCMAKE_VERBOSE_MAKEFILE=ON
=> Project : cryptopp v8.7.0 (547c96579c50)
-- The CXX compiler identification is GNU 4.8.4
-- The C compiler identification is GNU 4.8.4
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Crypto++ auto fetched at: /home/abdessattar/projects/cryptopp-cmake/build/external/ext_cryptopp-src
-- adding test: standard-cpm (/home/abdessattar/projects/cryptopp-cmake/build/test/test_standard-cpm)
=> Module : cryptopp
-- [cryptopp] CMake version 3.24.1
-- [cryptopp] System Linux
-- [cryptopp] Processor x86_64
-- [cryptopp] Performing Test CRYPTOPP_X86_SSE2
-- [cryptopp] Performing Test CRYPTOPP_X86_SSE2 - Success
-- [cryptopp] Performing Test CRYPTOPP_X86_SSSE3
-- [cryptopp] Performing Test CRYPTOPP_X86_SSSE3 - Success
-- [cryptopp] Performing Test CRYPTOPP_X86_SSE41
-- [cryptopp] Performing Test CRYPTOPP_X86_SSE41 - Success
-- [cryptopp] Performing Test CRYPTOPP_X86_SSE42
-- [cryptopp] Performing Test CRYPTOPP_X86_SSE42 - Success
-- [cryptopp] Performing Test CRYPTOPP_X86_CLMUL
-- [cryptopp] Performing Test CRYPTOPP_X86_CLMUL - Success
-- [cryptopp] Performing Test CRYPTOPP_X86_AES
-- [cryptopp] Performing Test CRYPTOPP_X86_AES - Success
-- [cryptopp] Performing Test CRYPTOPP_X86_AVX
-- [cryptopp] Performing Test CRYPTOPP_X86_AVX - Success
-- [cryptopp] Performing Test CRYPTOPP_X86_AVX2
-- [cryptopp] Performing Test CRYPTOPP_X86_AVX2 - Success
-- [cryptopp] Performing Test CRYPTOPP_X86_SHA
-- [cryptopp] Performing Test CRYPTOPP_X86_SHA - Failed
-- [cryptopp] Performing Test CRYPTOPP_MIXED_ASM
-- [cryptopp] Performing Test CRYPTOPP_MIXED_ASM - Success
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- [cryptopp] Generating cmake package config files
-- [cryptopp] Generating pkgconfig files
-- [cryptopp] Platform: x86_64
-- [cryptopp] Compiler definitions:  CRYPTOPP_DATA_DIR="/home/abdessattar/projects/cryptopp-cmake/build/external/ext_cryptopp-src";-DCRYPTOPP_DISABLE_SHANI
-- [cryptopp] Compiler options:   /Zi;/GR;/EHsc
-- [cryptopp] Build type: 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/abdessattar/projects/cryptopp-cmake/build
abdessattar@ubuntu:~/projects/cryptopp-cmake/build$ 

Notice the mistake in Compiler definitions: ... with a -D before the CRYPTOPP_DISABLE_SHANI...

abdessattar@ubuntu:~/projects/cryptopp-cmake/build$ make
/home/abdessattar/cmake-3.24.1-linux-x86_64/bin/cmake -S/home/abdessattar/projects/cryptopp-cmake -B/home/abdessattar/projects/cryptopp-cmake/build --check-build-system CMakeFiles/Makefile.cmake 0
/home/abdessattar/cmake-3.24.1-linux-x86_64/bin/cmake -E cmake_progress_start /home/abdessattar/projects/cryptopp-cmake/build/CMakeFiles /home/abdessattar/projects/cryptopp-cmake/build//CMakeFiles/progress.marks
make  -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/home/abdessattar/projects/cryptopp-cmake/build'
make  -f cryptopp/CMakeFiles/cryptopp-object.dir/build.make cryptopp/CMakeFiles/cryptopp-object.dir/depend
make[2]: Entering directory `/home/abdessattar/projects/cryptopp-cmake/build'
cd /home/abdessattar/projects/cryptopp-cmake/build && /home/abdessattar/cmake-3.24.1-linux-x86_64/bin/cmake -E cmake_depends "Unix Makefiles" /home/abdessattar/projects/cryptopp-cmake /home/abdessattar/projects/cryptopp-cmake/cryptopp /home/abdessattar/projects/cryptopp-cmake/build /home/abdessattar/projects/cryptopp-cmake/build/cryptopp /home/abdessattar/projects/cryptopp-cmake/build/cryptopp/CMakeFiles/cryptopp-object.dir/DependInfo.cmake --color=
make[2]: Leaving directory `/home/abdessattar/projects/cryptopp-cmake/build'
make  -f cryptopp/CMakeFiles/cryptopp-object.dir/build.make cryptopp/CMakeFiles/cryptopp-object.dir/build
make[2]: Entering directory `/home/abdessattar/projects/cryptopp-cmake/build'
[  1%] Building CXX object cryptopp/CMakeFiles/cryptopp-object.dir/__/external/ext_cryptopp-src/cryptlib.cpp.o
cd /home/abdessattar/projects/cryptopp-cmake/build/cryptopp && /usr/bin/c++  -D-DCRYPTOPP_DISABLE_SHANI -DCRYPTOPP_DATA_DIR=\"/home/abdessattar/projects/cryptopp-cmake/build/external/ext_cryptopp-src\"  -fPIC -MD -MT cryptopp/CMakeFiles/cryptopp-object.dir/__/external/ext_cryptopp-src/cryptlib.cpp.o -MF CMakeFiles/cryptopp-object.dir/__/external/ext_cryptopp-src/cryptlib.cpp.o.d -o CMakeFiles/cryptopp-object.dir/__/external/ext_cryptopp-src/cryptlib.cpp.o -c /home/abdessattar/projects/cryptopp-cmake/build/external/ext_cryptopp-src/cryptlib.cpp
<command-line>:0:1: error: macro names must be identifiers
make[2]: *** [cryptopp/CMakeFiles/cryptopp-object.dir/__/external/ext_cryptopp-src/cryptlib.cpp.o] Error 1
make[2]: Leaving directory `/home/abdessattar/projects/cryptopp-cmake/build'
make[1]: *** [cryptopp/CMakeFiles/cryptopp-object.dir/all] Error 2
make[1]: Leaving directory `/home/abdessattar/projects/cryptopp-cmake/build'
make: *** [all] Error 2

Fix it and run again...

abdessattar@ubuntu:~/projects/cryptopp-cmake/build$ make
...
[ 77%] Building CXX object cryptopp/CMakeFiles/cryptopp-object.dir/__/external/ext_cryptopp-src/zlib.cpp.o
make[2]: Leaving directory `/home/abdessattar/projects/cryptopp-cmake/build'
[ 87%] Built target cryptopp-object
make[2]: Entering directory `/home/abdessattar/projects/cryptopp-cmake/build'
make[2]: Leaving directory `/home/abdessattar/projects/cryptopp-cmake/build'
make[2]: Entering directory `/home/abdessattar/projects/cryptopp-cmake/build'
[ 88%] Linking CXX static library libcryptopp.a
make[2]: Leaving directory `/home/abdessattar/projects/cryptopp-cmake/build'
[ 88%] Built target cryptopp-static
make[2]: Entering directory `/home/abdessattar/projects/cryptopp-cmake/build'
make[2]: Leaving directory `/home/abdessattar/projects/cryptopp-cmake/build'
make[2]: Entering directory `/home/abdessattar/projects/cryptopp-cmake/build'
[ 89%] Linking CXX shared library libcryptopp.so
make[2]: Leaving directory `/home/abdessattar/projects/cryptopp-cmake/build'
[ 89%] Built target cryptopp-shared
...
[ 99%] Building CXX object cryptopp/CMakeFiles/cryptest.dir/__/external/ext_cryptopp-src/regtest3.cpp.o
[100%] Building CXX object cryptopp/CMakeFiles/cryptest.dir/__/external/ext_cryptopp-src/regtest4.cpp.o
[100%] Linking CXX executable cryptest
make[2]: Leaving directory `/home/abdessattar/projects/cryptopp-cmake/build'
[100%] Built target cryptest

Run tests, the build ones and the crypto++ ones...

abdessattar@ubuntu:~/projects/cryptopp-cmake/build$ ctest
Test project /home/abdessattar/projects/cryptopp-cmake/build
    Start 1: standard-cpm
1/3 Test #1: standard-cpm .....................   Passed    8.15 sec
    Start 2: build_cryptest
2/3 Test #2: build_cryptest ...................   Passed    0.13 sec
    Start 3: cryptest
3/3 Test #3: cryptest .........................   Passed   12.33 sec

100% tests passed, 0 tests failed out of 3

Total Test time (real) =  20.61 sec

Just git clone, cmake configure, build, test.

Honestly I can't rewrite the cmake script to work with an almost dead version of cmake... The new refactoring only requires cmake 3.1.0, which leaves a lot of bad habits and a lot of wrong ways of doing cmake intact for people who maintain a lot of legacy cmake projects....

If this cannot work, maybe we should create two repos, roll-back this one to the commit you had before, and I'll make a new repo for modern cmake people.

noloader commented 2 years ago

If this cannot work, maybe we should create two repos, roll-back this one to the commit you had before, and I'll make a new repo for modern cmake people.

+1.

abdes commented 2 years ago

The +1 is a Yes, right?

A new repo has been created (abdes/cryptopp-cmake), and will be dedicated to building crypto++ with modern CMake, i.e. 3.21+. It's great and it's C++ builds with pleasure, not pain 😃

@noloader please confirm you want me to roll back this repo to the latest commit you had...

chausner commented 2 years ago

A new repo has been created (abdes/cryptopp-cmake), and will be dedicated to building crypto++ with modern CMake, i.e. 3.21+. It's great and it's C++ builds with pleasure, not pain 😃

It's great to see effort put into modernizing the build system and providing CMake wrappers for the excellent underlying library that really deserves great tooling. On the other hand, it's a bit sad that we now have two external CMake wrappers for the library and still none in the original repository. I suspect that over time, they will further drift apart which means also twice the amount of effort will be needed to keep them updated in the long run.

I also fear that, since your fork uses the same name, it might get confusing in the future which of the two a dependent library is compatible with.

noloader commented 2 years ago

@abdes,

A new repo has been created (abdes/cryptopp-cmake), and will be dedicated to building crypto++ with modern CMake, i.e. 3.21+. It's great and it's C++ builds with pleasure, not pain

Very good. Perfect.

I am going to turn this repo read-only for historical purposes. I will point folks to your GitHub for Cmake and Crypto++ 8.7.0 moving forward. I'll update the docs.

You may want to sign up for a wiki account so you can update https://www.cryptopp.com/wiki/CMake. Anyone on the team you are assembling is welcome to join and keep the doc current.

Thanks for taking it on!

MarcelRaad commented 2 years ago

@abdes Please also mirror the tags then, or at least one for 8.7.0. Thanks for all the work!

noloader commented 2 years ago

@abdes,

please confirm you want me to roll back this repo to the latest commit you had.

I'll leave this decision to you now that you maintain the CMake sources :) Tell me what you would like to do.

abdes commented 2 years ago

@abdes Please also mirror the tags then, or at least one for 8.7.0. Thanks for all the work!

Sure, it will be done before tomorrow... I'm doing more refactoring and cleanup before I release the tag for 8.7.0.

noloader commented 2 years ago

@abdes,

You may want to grab an account at the GCC Compile Farm. Accounts are free to folks who are working on free and open source software. See the "request an Account" link at the top of the page. You can cite Crypto++ or CC me in emails (noloader, gmail account).

The GCC Compile Farm provides access to a lot of hardware, operating systems and compilers. I use it frequently for testing and it provides a lot of value. I think it will benefit you, too.

abdes commented 2 years ago

My decision is clear. I cannot fix this repo with CMake 2. I will roll it back and unfortunately stop maintaining it. I do not use old versions in my projects and don't have the time to do so.

The new repo is already setup and will be ready by tomorrow. It is a modern cmake build project by design and will always be as such. I will add a link to it in the README for people who want to make the move to modern cmake.

Regarding GCC farm, I have applied long time ago and still waiting for no-reply :-)

Again, we need people who need odd version to step up, and suggest fixes/changes for their platform/arch/cmake/compiler/whatever...

noloader commented 2 years ago

@abdes,

I hope I did not jump the gun here... I announced the new cryptopp-cmake project on the mailing list at Change of CMake maintainers.

Thanks for taking it on!

noloader commented 2 years ago

@abdes,

My notes have a bullet item that we were missing a FindCryptopp.cmake file. I could not find information of a CMake find file, and Kitware had closed their mailing list so I could not ask a question. If you know something about CMake find files, you might consider adding one.

Vollstrecker commented 2 years ago

That's a thing i have on my ToDo. But it will be a Cryptopp_config.cmake so it will be found using FindPackage.

abdes commented 2 years ago

@abdes,

I hope I did not jump the gun here... I announced the new cryptopp-cmake project on the mailing list at Change of CMake maintainers.

Thanks for taking it on!

It's cool. Repo almost done. Lots of stuff to remove that was not working before. I am also forbidding shared library builds as I understood your taking out the FIPS DLL, and crypto++ does not export symbols properly for a general DLL build. From now on, only static lib build is allowed. The cmake script DOES support both builds.

@Vollstrecker please check the new repo (master tag) and see if the install artifacts would be fine with you. There is a cryptoppConfig.cmake over there.

image

I'd love for you to contribute if something is not as it should be.

abdes commented 2 years ago

@noloader It's done, the repo is back to state at which it was before I commit my changes. README updated to reflect end of maintenance and redirect to the new repo.

abdes commented 2 years ago

@chausner @Vollstrecker @noloader you have an invitation to be a collaborator in the new repo.