From f45f955719138529fa97659ee15f7b54120a5cb4 Mon Sep 17 00:00:00 2001 From: Leandro Pereira Date: Fri, 6 Apr 2012 11:57:54 -0300 Subject: [PATCH] Enable optimizations while building in release mode 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. --- CMakeLists.txt | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ba7679fe..4e52c8d9f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,11 @@ cmake_minimum_required(VERSION 2.6) 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_library(TCMALLOC_LIBRARY NAMES tcmalloc /usr/lib /usr/local/lib) if (TCMALLOC_LIBRARY) @@ -20,7 +25,8 @@ else () message(STATUS "Valgrind headers not found -- disabling valgrind support") endif() -add_library(wan +add_executable(lwan + main.c lwan.c lwan-coro.c lwan-trie.c @@ -33,16 +39,7 @@ add_library(wan 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 - wan ${CMAKE_THREAD_LIBS_INIT} ${TCMALLOC_LIBRARY} )