janbar / openssl-cmake

Build OpenSSL with CMake on MacOS, Win32, Win64 and cross compile for Android, IOS
Other
267 stars 138 forks source link

For the God, don't destroy cplusplus project. #11

Open Ron2014 opened 4 years ago

Ron2014 commented 4 years ago

For the God, don't destroy cplusplus project.

My job is intergrate openssl to the c++ project of our team by cmake , and I found your repo, this repo.

Really nice repo.

But when I found the code in openssl-cmake/CMakeLists.txt:

...
if( MSVC )
  include( MSVCRuntime )
  configure_msvc_runtime()
...

MSVCRuntime.cmake this file change all the C++ compiler options, make my project don't understand c++ syntax like:

syntax error: identifier '...'

Finally, I remove these two lines and get everything well.

  include( MSVCRuntime )
  configure_msvc_runtime()

Wish you consider about it.

For detail

snapshot

my wiki

janbar commented 4 years ago

The new commit f0d9bcb4e6336e7a8c7b614e176cb1cf78bfda4b could help. The project requires a minimal configuration for MSVC. I cannot remove completely the runtime configuration because existing projects using this repos need it. Let me know if it works for you with the commit above, or an option could be added to bypass configure_msvc_runtime.

Ron2014 commented 4 years ago

Good Job, Buddy.

Good news, it works. only comment these lines:

        # set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}")
        # set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
        # set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
        # set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL}")
        # set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
dmenendez-gruposantander commented 2 years ago

Another issue with cmake/MSVCRuntime.cmake: it replaces /Ob0 with /Ob2 globally! Now I'm unable to properly debug my own code because you choose to change global compilation flags, This is very very bad!

Two questions: 1) why oh why do you change that /Ob option? even in Debug? 2) why can't you use a more modern CMake style using target_compile_options(), so you don't mess with global compile options?

janbar commented 2 years ago

You can fork it and make all changes you need for your project.

dmenendez-gruposantander commented 2 years ago

You can fork it and make all changes you need for your project.

But why would you change /Ob0 to /Ob2 in Debug mode?

Also, would you accept a PR that left the /Ob0 there in Debug mode?