CMakeLists.txt 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. project(lua CXX)
  2. set(LUA_VERSION_MAJOR 5)
  3. set(LUA_VERSION_MINOR 1)
  4. set(LUA_VERSION_PATCH 4)
  5. set(LUA_VERSION "${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}.${LUA_VERSION_PATCH}")
  6. set(COMMON_CFLAGS)
  7. set(COMMON_LDFLAGS)
  8. set(LIBS)
  9. if(APPLE)
  10. set(DEFAULT_POSIX TRUE)
  11. set(DEFAULT_DLOPEN OFF)
  12. set(COMMON_CFLAGS "${COMMON_CFLAGS} -DLUA_USE_MACOSX")
  13. elseif(UNIX OR CYGWIN)
  14. set(DEFAULT_POSIX TRUE)
  15. elseif(WIN32)
  16. set(LUA_WIN TRUE)
  17. set(COMMON_CFLAGS "${COMMON_CFLAGS} -DLUA_BUILD_AS_DLL")
  18. else()
  19. set(DEFAULT_ANSI TRUE)
  20. endif()
  21. if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
  22. set(COMMON_LDFLAGS "${COMMON_LDFLAGS} -Wl,-E -lm")
  23. set(DEFAULT_DLOPEN ON)
  24. endif()
  25. option(LUA_USE_DLOPEN "Enable dlopen support." ${DEFAULT_DLOPEN})
  26. mark_as_advanced(LUA_USE_DLOPEN)
  27. option(LUA_ANSI "Disable non-ANSI features." ${DEFAULT_ANSI})
  28. mark_as_advanced(LUA_ANSI)
  29. if(LUA_USE_DLOPEN)
  30. set(COMMON_CFLAGS "${COMMON_CFLAGS} -DLUA_USE_DLOPEN")
  31. if(NOT APPLE)
  32. set(COMMON_LDFLAGS "${COMMON_LDFLAGS} -ldl ")
  33. endif(NOT APPLE)
  34. endif(LUA_USE_DLOPEN)
  35. if(DEFAULT_POSIX)
  36. set(COMMON_CFLAGS "${COMMON_CFLAGS} -DLUA_USE_POSIX")
  37. endif(DEFAULT_POSIX)
  38. if(LUA_ANSI)
  39. set(COMMON_CFLAGS "${COMMON_CFLAGS} -DLUA_ANSI")
  40. endif(LUA_ANSI)
  41. # Standard flags to use
  42. if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|(Apple)?Clang")
  43. set(COMMON_CFLAGS "${COMMON_CFLAGS} -pipe -Wall -Wextra -Wshadow -W -pedantic")
  44. endif()
  45. # COMMON_CFLAGS has no effect without this line
  46. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_CFLAGS}")
  47. add_subdirectory(src)