Skip to content

Commit

Permalink
Enable optimizations while building in release mode
Browse files Browse the repository at this point in the history
In order to use GCC's -flto with standard ld, lwan.a isn't generated; the
binary is built by linking with the object files directly.
  • Loading branch information
lpereira committed Apr 6, 2012
1 parent 3caa2e8 commit f45f955
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions CMakeLists.txt
Expand Up @@ -3,6 +3,11 @@ cmake_minimum_required(VERSION 2.6)


set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wshadow") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wshadow")


if (${CMAKE_BUILD_TYPE} MATCHES "Release")
message(STATUS "Enabling compiler optimizations")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mtune=native -O3 -flto")
endif ()

find_package(Threads) find_package(Threads)
find_library(TCMALLOC_LIBRARY NAMES tcmalloc /usr/lib /usr/local/lib) find_library(TCMALLOC_LIBRARY NAMES tcmalloc /usr/lib /usr/local/lib)
if (TCMALLOC_LIBRARY) if (TCMALLOC_LIBRARY)
Expand All @@ -20,7 +25,8 @@ else ()
message(STATUS "Valgrind headers not found -- disabling valgrind support") message(STATUS "Valgrind headers not found -- disabling valgrind support")
endif() endif()


add_library(wan add_executable(lwan
main.c
lwan.c lwan.c
lwan-coro.c lwan-coro.c
lwan-trie.c lwan-trie.c
Expand All @@ -33,16 +39,7 @@ add_library(wan
strbuf.c strbuf.c
) )


target_link_libraries(wan
${CMAKE_THREAD_LIBS_INIT})
set_target_properties(wan
PROPERTIES PREFIX "l")

add_executable(lwan
main.c)

target_link_libraries(lwan target_link_libraries(lwan
wan
${CMAKE_THREAD_LIBS_INIT} ${CMAKE_THREAD_LIBS_INIT}
${TCMALLOC_LIBRARY} ${TCMALLOC_LIBRARY}
) )

0 comments on commit f45f955

Please sign in to comment.