comparison CMakeLists.txt @ 0:4b915342e2a8

LuaSocket 2.0.2 + CMake build description.
author Eric Wing <ewing . public |-at-| gmail . com>
date Tue, 26 Aug 2008 18:40:01 -0700
parents
children cf0892e34f45
comparison
equal deleted inserted replaced
-1:000000000000 0:4b915342e2a8
1 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
2 PROJECT(LuaSocket)
3
4 IF(USING_LUA_MULTI_SET)
5 IF(NOT LUA_LIBRARIES)
6 IF(lua_library_dynamic)
7 SET(LUA_LIBRARIES lua_library_dynamic)
8 ELSE(lua_library_dynamic)
9 SET(LUA_LIBRARIES lua_library_static)
10 ENDIF(lua_library_dynamic)
11 ENDIF(NOT LUA_LIBRARIES)
12 IF(NOT LUA_INCLUDE_DIR)
13 SET(LUA_INCLUDE_DIR ${Lua_SOURCE_DIR}/src)
14 ENDIF(NOT LUA_INCLUDE_DIR)
15 ELSE(USING_LUA_MULTI_SET)
16 FIND_PACKAGE(Lua51 REQUIRED)
17 ENDIF(USING_LUA_MULTI_SET)
18
19 OPTION(WANTS_BUILD_SHARED_LIBRARY "Set to ON to build dynamic library." ON)
20 #OPTION(WANTS_BUILD_STATIC_LIBRARY "Set to ON to build static library." ON)
21 OPTION(WANTS_BUILD_FRAMEWORK "Set to ON to build framework instead of dylib. Only valid if BUILD_SHARED_LIBRARY is ON an is OS X." ON)
22
23 SET(LUAPACKAGE_CDIR "lib/lua/5.1" CACHE STRING "Path for Lua packaged platform specific things.")
24 SET(LUAPACKAGE_LDIR "share/lua/5.1" CACHE STRING "Path for Lua packages platform independent things.")
25
26 IF(APPLE)
27 SET(LUASOCKET_LINK_FLAGS "-undefined dynamic_lookup")
28 SET(LUASOCKET_C_FLAGS "-fno-common -pedantic")
29 ADD_DEFINITIONS(-DLUASOCKET_DEBUG -DUNIX_HAS_SUN_LEN)
30 ENDIF(APPLE)
31
32
33 INCLUDE_DIRECTORIES(
34 ${LUA_INCLUDE_DIR}
35 )
36
37
38
39 #IF(WANTS_BUILD_SHARED_LIBRARY AND WANTS_BUILD_FRAMEWORK)
40 # SET_TARGET_PROPERTIES(luasocket_library_dynamic PROPERTIES
41 # FRAMEWORK TRUE
42 # # FRAMEWORK_VERSION 5.1
43 # # PRIVATE_HEADER "fooPrivate.h;fooBoth.h"
44 # PUBLIC_HEADER "${luasocket_PUBLIC_HEADERS}"
45 # RESOURCE "${RESOURCE_FILES}"
46 # INSTALL_NAME_DIR "@executable_path/../Frameworks"
47 # BUILD_WITH_INSTALL_RPATH 1 # FIXME: User option or Xcode=1
48 # )
49 #ENDIF(WANTS_BUILD_SHARED_LIBRARY AND WANTS_BUILD_FRAMEWORK)
50
51 #SET_TARGET_PROPERTIES(luasocket_library_dynamic PROPERTIES
52 # PUBLIC_HEADER "${luasocket_PUBLIC_HEADERS}"
53 # RESOURCE "${luasocket_RESOURCE_FILES}"
54 #)
55
56
57 IF(NOT USING_LUA_MULTI_SET)
58 # For uninstall (needs cmake_uninstall.cmake.in in the top-level directory)
59 CONFIGURE_FILE(
60 "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
61 "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
62 IMMEDIATE @ONLY)
63 ADD_CUSTOM_TARGET(uninstall
64 "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
65 ENDIF(NOT USING_LUA_MULTI_SET)
66
67
68
69 # Set defaults for Universal Binaries. We want 32-bit Intel/PPC on 10.4
70 # and 32/64-bit Intel/PPC on >= 10.5. Anything <= 10.3 doesn't support.
71 IF(APPLE)
72 # These are just defaults/recommendations, but how we want to build
73 # out of the box. But the user needs to be able to change these options.
74 # So we must only set the values the first time CMake is run, or we
75 # will overwrite any changes the user sets.
76 # FORCE is used because the options are not reflected in the UI otherwise.
77 # Seems like a good place to add version specific compiler flags too.
78 IF(NOT LUA_CONFIG_HAS_BEEN_RUN_BEFORE)
79 # This is really fragile, but CMake doesn't provide the OS system
80 # version information we need. (Darwin versions can be changed
81 # independently of OS X versions.)
82 # It does look like CMake handles the CMAKE_OSX_SYSROOT automatically.
83 IF(EXISTS /Developer/SDKs/MacOSX10.5.sdk)
84 SET(CMAKE_OSX_ARCHITECTURES "ppc;i386;ppc64;x86_64" CACHE STRING "Build architectures for OSX" FORCE)
85 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mmacosx-version-min=10.5" CACHE STRING "Flags used by the compiler during all build types." FORCE)
86 ELSE(EXISTS /Developer/SDKs/MacOSX10.5.sdk)
87 IF(EXISTS /Developer/SDKs/MacOSX10.4u.sdk)
88 SET(CMAKE_OSX_ARCHITECTURES "ppc;i386" CACHE STRING "Build architectures for OSX" FORCE)
89 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mmacosx-version-min=10.4" CACHE STRING "Flags used by the compiler during all build types." FORCE)
90 ELSE(EXISTS /Developer/SDKs/MacOSX10.4u.sdk)
91 # No Universal Binary support
92 # Should break down further to set the -mmacosx-version-min,
93 # but the SDK detection is too unreliable here.
94 ENDIF(EXISTS /Developer/SDKs/MacOSX10.4u.sdk)
95 ENDIF(EXISTS /Developer/SDKs/MacOSX10.5.sdk)
96 ENDIF(NOT LUA_CONFIG_HAS_BEEN_RUN_BEFORE)
97 ENDIF(APPLE)
98
99 # This needs to be run very last so other parts of the scripts can take
100 # advantage of this.
101 IF(NOT LUA_CONFIG_HAS_BEEN_RUN_BEFORE)
102 SET(LUA_CONFIG_HAS_BEEN_RUN_BEFORE 1 CACHE INTERNAL "Flag to track whether this is the first time running CMake or if CMake has been configured before")
103 ENDIF(NOT LUA_CONFIG_HAS_BEEN_RUN_BEFORE)
104
105
106 ADD_SUBDIRECTORY(src)