2
0

CMakeLists.txt 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. cmake_minimum_required(VERSION 2.4 FATAL_ERROR)
  2. project(lua C)
  3. set(LUA_VERSION_MAJOR 5)
  4. set(LUA_VERSION_MINOR 1)
  5. set(LUA_VERSION_PATCH 4)
  6. set(LUA_VERSION "${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}.${LUA_VERSION_PATCH}")
  7. set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
  8. set(COMMON_CFLAGS)
  9. set(COMMON_LDFLAGS)
  10. set(LIBS)
  11. if(APPLE)
  12. set(DEFAULT_POSIX TRUE)
  13. set(DEFAULT_DLOPEN ON)
  14. # use this on Mac OS X 10.3-
  15. option(LUA_USE_MACOSX "Mac OS X 10.3-" OFF)
  16. elseif(UNIX OR CYGWIN)
  17. set(DEFAULT_POSIX TRUE)
  18. elseif(WIN32)
  19. set(LUA_WIN TRUE)
  20. set(COMMON_CFLAGS "${COMMON_CFLAGS} -DLUA_BUILD_AS_DLL")
  21. else()
  22. set(DEFAULT_ANSI TRUE)
  23. endif()
  24. if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
  25. set(COMMON_LDFLAGS "${COMMON_LDFLAGS} -Wl,-E -lm")
  26. set(DEFAULT_DLOPEN ON)
  27. endif()
  28. # For "Mac OS X 10.3-"
  29. if(LUA_USE_MACOSX)
  30. set(COMMON_CFLAGS "${COMMON_CFLAGS} -DLUA_USE_MACOSX")
  31. set(LUA_USE_DLOPEN FALSE)
  32. endif(LUA_USE_MACOSX)
  33. option(LUA_USE_DLOPEN "Enable dlopen support." ${DEFAULT_DLOPEN})
  34. mark_as_advanced(LUA_USE_DLOPEN)
  35. option(LUA_ANSI "Disable non-ANSI features." ${DEFAULT_ANSI})
  36. mark_as_advanced(LUA_ANSI)
  37. if(LUA_USE_DLOPEN)
  38. set(COMMON_CFLAGS "${COMMON_CFLAGS} -DLUA_USE_DLOPEN")
  39. if(NOT APPLE)
  40. set(COMMON_LDFLAGS "${COMMON_LDFLAGS} -ldl ")
  41. endif(NOT APPLE)
  42. endif(LUA_USE_DLOPEN)
  43. if(DEFAULT_POSIX)
  44. set(COMMON_CFLAGS "${COMMON_CFLAGS} -DLUA_USE_POSIX")
  45. endif(DEFAULT_POSIX)
  46. if(LUA_ANSI)
  47. set(COMMON_CFLAGS "${COMMON_CFLAGS} -DLUA_ANSI")
  48. endif(LUA_ANSI)
  49. # COMMON_CFLAGS has no effect without this line
  50. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_CFLAGS}")
  51. # Standard flags to use for each build type.
  52. if(CMAKE_COMPILER_IS_GNUCC)
  53. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pipe -Wall -Wextra -Wshadow -W -pedantic -std=gnu99")
  54. set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2")
  55. set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -g")
  56. set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_PROFILE} -O1 -g")
  57. set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_WITHDEBINFO} -O2 -g")
  58. endif(CMAKE_COMPILER_IS_GNUCC)
  59. add_subdirectory(src build)