setup_build.cmake 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # Copyright 2017 The Effcee Authors.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. if(NOT COMMAND find_host_package)
  15. macro(find_host_package)
  16. find_package(${ARGN})
  17. endmacro()
  18. endif()
  19. find_host_package(Python3)
  20. option(DISABLE_RTTI "Disable RTTI in builds")
  21. if(DISABLE_RTTI)
  22. if(UNIX)
  23. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
  24. endif(UNIX)
  25. endif(DISABLE_RTTI)
  26. option(DISABLE_EXCEPTIONS "Disables exceptions in builds")
  27. if(DISABLE_EXCEPTIONS)
  28. if(UNIX)
  29. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
  30. endif(UNIX)
  31. endif(DISABLE_EXCEPTIONS)
  32. if(WIN32)
  33. # Ensure that gmock compiles the same as the rest of the code, otherwise
  34. # failures will occur.
  35. set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
  36. endif(WIN32)
  37. if(WIN32)
  38. # On Windows, CMake by default compiles with the shared CRT.
  39. # Default it to the static CRT.
  40. option(EFFCEE_ENABLE_SHARED_CRT
  41. "Use the shared CRT with MSVC instead of the static CRT"
  42. ${EFFCEE_ENABLE_SHARED_CRT})
  43. if (NOT EFFCEE_ENABLE_SHARED_CRT)
  44. # Tell MSVC to Link executables statically.
  45. set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
  46. endif(NOT EFFCEE_ENABLE_SHARED_CRT)
  47. endif(WIN32)