[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[creduce-bugs] [PATCH] Updates to cmake configuration.



Hi,
I have made some small changes to the cmake configuration. The first patch makes the cmake configuration work on linux and the second enable assertions in the debug configuration. Perhaps they are useful enough to be included in the main repository.

Sincerely,
Johan Bengtsson
>From 163529d4a43ce825e9e941b87d25d94734f7af7f Mon Sep 17 00:00:00 2001
From: Johan Bengtsson <johan.bengtsson@iar.com>
Date: Wed, 12 Aug 2015 16:54:19 +0200
Subject: [PATCH 2/3] Update compile definitions handling in cmake config

Only define NDEBUG when building in release mode. In debug-node define
ENABLE_TRANS_ASSERT instead, to enable all assertions.
---
 clang_delta/CMakeLists.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang_delta/CMakeLists.txt b/clang_delta/CMakeLists.txt
index c863d48..be66c3f 100755
--- a/clang_delta/CMakeLists.txt
+++ b/clang_delta/CMakeLists.txt
@@ -20,7 +20,8 @@ set(LLVM_VERSION ${LLVM_VERSION_MAJOR}${LLVM_VERSION_MINOR})
 
 # Add flags for LLVM
 add_definitions(${LLVM_DEFINITIONS})
-add_definitions(-DHAVE_CONFIG_H -DNDEBUG)
+set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS HAVE_CONFIG_H
+  $<$<CONFIG:Release>:NDEBUG> $<$<CONFIG:Debug>:ENABLE_TRANS_ASSERT>)
 include_directories(${LLVM_INCLUDE_DIRS})
 include_directories(${CMAKE_BINARY_DIR})
 link_directories(${LLVM_LIBRARY_DIRS})
-- 
1.9.1

>From 52fd19aa0ba558cb02aaae5211ce357eaac994cf Mon Sep 17 00:00:00 2001
From: Johan Bengtsson <johan.bengtsson@iar.com>
Date: Wed, 12 Aug 2015 16:49:12 +0200
Subject: [PATCH 1/3] Update cmake configuration to work on linux

There were three main problems with using the cmake configuration on
linux.

1) The names of the needed programs are hardcoded to end in .exe instead
of using ${CMAKE_EXECUTABLE_SUFFIX}.

2) The clang libraries are listed in the wrong order for a one-pass
linker.

3) GCC and Clang needs -std=c++11 and -fno-rtti

This change set addresses all of those problems.
---
 CMakeLists.txt             |  5 +++++
 clang_delta/CMakeLists.txt | 14 +++++++-------
 creduce/CMakeLists.txt     | 16 ++++++++--------
 3 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9afdbc4..8e04cc6 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -41,6 +41,11 @@ string(STRIP "${creduce_GIT_HASH}" creduce_GIT_HASH)
 #    set(STDC_HEADERS 1)
 #endif(freeExists)
 
+if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+  set(CMAKE_CXX_FLAGS "-std=c++11 -fno-rtti -Wall -Wextra -Wno-long-long -Wno-unused-parameter")
+  set(CMAKE_CXX_FLAGS_RELEASE "-O3 -fno-strict-aliasing")
+endif()
+
 #FIXME: Should be determined automatically
 set(YYTEXT_POINTER 1)
 
diff --git a/clang_delta/CMakeLists.txt b/clang_delta/CMakeLists.txt
index 344933e..c863d48 100755
--- a/clang_delta/CMakeLists.txt
+++ b/clang_delta/CMakeLists.txt
@@ -33,16 +33,16 @@ llvm_map_components_to_libnames(LLVM_LIBS
 
 set(CLANG_LIBS
   clangRewrite
-  clangAnalysis
-  clangAST
-  clangBasic
-  clangDriver
-  clangEdit
   clangFrontend
-  clangLex
   clangParse
   clangSema
   clangSerialization
+  clangAnalysis
+  clangEdit
+  clangLex
+  clangAST
+  clangDriver
+  clangBasic
 )
 
 set(TRANSFORMATION_HEADERS
@@ -198,7 +198,7 @@ add_executable(clang_delta
   TransformationManager.cpp
 )
 
-target_link_libraries(clang_delta ${LLVM_LIBS} ${CLANG_LIBS})
+target_link_libraries(clang_delta ${CLANG_LIBS} ${LLVM_LIBS})
 
 install(TARGETS clang_delta
   RUNTIME DESTINATION "bin"
diff --git a/creduce/CMakeLists.txt b/creduce/CMakeLists.txt
index a84c88c..b3a61be 100755
--- a/creduce/CMakeLists.txt
+++ b/creduce/CMakeLists.txt
@@ -9,24 +9,24 @@ project(creduce_perl)
 
 include(FindPerl)
 
-find_program(ASTYLE "astyle.exe")
+find_program(ASTYLE "astyle${CMAKE_EXECUTABLE_SUFFIX}")
 if(NOT ASTYLE)
-message(WARNING "astyle.exe could not be found! Set ASTYLE manually.")
+message(WARNING "astyle${CMAKE_EXECUTABLE_SUFFIX} could not be found! Set ASTYLE manually.")
 endif(NOT ASTYLE)
 
-find_program(CLANG_FORMAT "clang-format.exe")
+find_program(CLANG_FORMAT "clang-format${CMAKE_EXECUTABLE_SUFFIX}")
 if(NOT CLANG_FORMAT)
-message(WARNING "clang-format.exe could not be found! Set CLANG_FORMAT manually.")
+message(WARNING "clang-format${CMAKE_EXECUTABLE_SUFFIX} could not be found! Set CLANG_FORMAT manually.")
 endif(NOT CLANG_FORMAT)
 
-find_program(INDENT "indent.exe")
+find_program(INDENT "indent${CMAKE_EXECUTABLE_SUFFIX}")
 if(NOT INDENT)
-message(WARNING "indent.exe could not be found! Set INDENT manually.")
+message(WARNING "indent${CMAKE_EXECUTABLE_SUFFIX} could not be found! Set INDENT manually.")
 endif(NOT INDENT)
 
-find_program(TOPFORMFLAT "topformflat.exe")
+find_program(TOPFORMFLAT "topformflat${CMAKE_EXECUTABLE_SUFFIX}")
 if(NOT TOPFORMFLAT)
-message(WARNING "topformflat.exe could not be found! Set TOPFORMFLAT manually.")
+message(WARNING "topformflat${CMAKE_EXECUTABLE_SUFFIX} could not be found! Set TOPFORMFLAT manually.")
 endif(NOT TOPFORMFLAT)
 
 # Prepare creduce.pl
-- 
1.9.1