comparison CMakeLists.txt @ 23:907d517d37c6

CMake: Set Release configuration as default. CMake: Strip examples on linux (on windows now disabled). CMake: Install opengl32.lib and glu32.lib on windows.
author SokoL_SD
date Fri, 15 May 2009 11:28:39 +0000
parents 3925148ba2b6
children ebdd676d0b60
comparison
equal deleted inserted replaced
22:49d696a4e5f3 23:907d517d37c6
22 set(packages) 22 set(packages)
23 foreach(package ${packages_big}) 23 foreach(package ${packages_big})
24 string(TOLOWER ${package} package) 24 string(TOLOWER ${package} package)
25 set(packages ${packages} ${package}) 25 set(packages ${packages} ${package})
26 endforeach(package ${packages_big}) 26 endforeach(package ${packages_big})
27
28 ## Strip utility.
29 find_program(STRIP strip)
27 30
28 ## Find D compiler and parsing its version. 31 ## Find D compiler and parsing its version.
29 find_program(DC dmd ldc) 32 find_program(DC dmd ldc)
30 if (DC) 33 if (DC)
31 exec_program(${DC} ARGS "" OUTPUT_VARIABLE d_output) 34 exec_program(${DC} ARGS "" OUTPUT_VARIABLE d_output)
81 set(D_TARGET ) ## TODO: hm... I don`t known this parameter for D2 ^( 84 set(D_TARGET ) ## TODO: hm... I don`t known this parameter for D2 ^(
82 endif(D_VERSION EQUAL "1") 85 endif(D_VERSION EQUAL "1")
83 set(D_FLAGS ${D_FLAGS} -I${CMAKE_SOURCE_DIR}/qt/d${D_VERSION}) 86 set(D_FLAGS ${D_FLAGS} -I${CMAKE_SOURCE_DIR}/qt/d${D_VERSION})
84 87
85 # Debug and release flags. 88 # Debug and release flags.
86 if (${CMAKE_BUILD_TYPE} MATCHES [dD][eE][bB][uU][gG]) 89 if (NOT CMAKE_BUILD_TYPE)
87 #set(CMAKE_BUILD_TYPE Debug) 90 set(CMAKE_BUILD_TYPE Release)
88 #set( SUFFIXLIB "${SUFFIXLIB}-debug" ) 91 endif (NOT CMAKE_BUILD_TYPE)
89 #set( SUFFIXBIN "${SUFFIXBIN}-debug" ) 92 if(${CMAKE_BUILD_TYPE} MATCHES [dD][eE][bB][uU][gG])
90 add_definitions(-DDEBUG) 93 set(CMAKE_BUILD_TYPE Debug)
91 set(D_FLAGS ${D_FLAGS} -g -gc -debug) 94 #set( SUFFIXLIB "${SUFFIXLIB}-debug" )
92 else (${CMAKE_BUILD_TYPE} MATCHES [dD][eE][bB][uU][gG]) 95 #set( SUFFIXBIN "${SUFFIXBIN}-debug" )
93 #set(CMAKE_BUILD_TYPE Release) 96 add_definitions(-DDEBUG)
94 add_definitions(-UNO_DEBUG) 97 set(D_FLAGS ${D_FLAGS} -g -gc -debug)
98 elseif (NOT ${CMAKE_BUILD_TYPE} MATCHES [rR][eE][lL][eE][aA][sS])
99 message(STATUS "Only debug and release configuration are now supproted. Configuration changed to 'Release'")
100 set(CMAKE_BUILD_TYPE Release)
101 endif (${CMAKE_BUILD_TYPE} MATCHES [dD][eE][bB][uU][gG])
102 if (${CMAKE_BUILD_TYPE} MATCHES [rR][eE][lL][eE][aA][sS])
103 #add_definitions(-UNO_DEBUG)
95 set(D_FLAGS ${D_FLAGS} -O -release -inline) 104 set(D_FLAGS ${D_FLAGS} -O -release -inline)
96 if(D_IS_MARS) 105 if(D_IS_MARS)
97 set(D_FLAGS ${D_FLAGS} -inline) 106 set(D_FLAGS ${D_FLAGS} -inline)
98 elseif(D_IS_LLVM) 107 elseif(D_IS_LLVM)
99 set(D_FLAGS ${D_FLAGS} -enable-inlining) 108 set(D_FLAGS ${D_FLAGS} -enable-inlining)
100 endif(D_IS_MARS) 109 endif(D_IS_MARS)
101 if(${CMAKE_SYSTEM_NAME} STREQUAL Windows) 110 if(${CMAKE_SYSTEM_NAME} STREQUAL Windows)
102 set(D_FLAGS ${D_FLAGS} -L/subsystem:windows) 111 set(D_FLAGS ${D_FLAGS} -L/subsystem:windows)
103 endif(${CMAKE_SYSTEM_NAME} STREQUAL Windows) 112 endif(${CMAKE_SYSTEM_NAME} STREQUAL Windows)
104 endif (${CMAKE_BUILD_TYPE} MATCHES [dD][eE][bB][uU][gG]) 113 endif(${CMAKE_BUILD_TYPE} MATCHES [rR][eE][lL][eE][aA][sS] )
114
105 set(D_FLAGS ${D_FLAGS} -I${CMAKE_BINARY_DIR} -I${CMAKE_SOURCE_DIR}) 115 set(D_FLAGS ${D_FLAGS} -I${CMAKE_BINARY_DIR} -I${CMAKE_SOURCE_DIR})
106 if(D_IS_MARS AND ${CMAKE_SYSTEM_NAME} STREQUAL Windows) 116 if(D_IS_MARS AND ${CMAKE_SYSTEM_NAME} STREQUAL Windows)
107 else(D_IS_MARS AND ${CMAKE_SYSTEM_NAME} STREQUAL Windows) 117 else(D_IS_MARS AND ${CMAKE_SYSTEM_NAME} STREQUAL Windows)
108 set(D_FLAGS ${D_FLAGS} -L-L${CMAKE_BINARY_DIR}/lib) 118 set(D_FLAGS ${D_FLAGS} -L-L${CMAKE_BINARY_DIR}/lib)
109 endif(D_IS_MARS AND ${CMAKE_SYSTEM_NAME} STREQUAL Windows) 119 endif(D_IS_MARS AND ${CMAKE_SYSTEM_NAME} STREQUAL Windows)
309 DEPENDS ${objects} 319 DEPENDS ${objects}
310 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 320 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
311 COMMENT "Building example ${name}" 321 COMMENT "Building example ${name}"
312 ) 322 )
313 add_custom_target(example_${name} ALL DEPENDS "${output}") 323 add_custom_target(example_${name} ALL DEPENDS "${output}")
324 ## TODO: Enable on windows too.
325 if(STRIP AND ${CMAKE_BUILD_TYPE} EQUAL "Release" AND ${CMAKE_SYSTEM_NAME} STREQUAL Linux) ##
326 add_custom_command(TARGET example_${name} POST_BUILD COMMAND "${STRIP}" ARGS "${output}")
327 endif(STRIP AND ${CMAKE_BUILD_TYPE} EQUAL "Release" AND ${CMAKE_SYSTEM_NAME} STREQUAL Linux)
314 add_dependencies(example_${name} allpackages) 328 add_dependencies(example_${name} allpackages)
315 endmacro(build_example sources) 329 endmacro(build_example sources)
316 330
317 ##-------------------------------------------- 331 ##--------------------------------------------
318 ## Build library. 332 ## Build and install library.
319 ##-------------------------------------------- 333 ##--------------------------------------------
320 add_subdirectory(generator) 334 add_subdirectory(generator)
321 file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 335 file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
322 add_custom_target(allpackages ALL) 336 add_custom_target(allpackages ALL)
323 link_directories(${CMAKE_BINARY_DIR}/CMakeFiles) 337 link_directories(${CMAKE_BINARY_DIR}/CMakeFiles)