Browse Source

[MERGE #423] linux: fix build

Merge pull request #423 from xanlpz:linux-cmake
commit 29bbe86ffa0912fc9c45 broke the build on some GNU/Linux
configurations, since CMAKE_CXX_FLAGS is not always used. Use
add_definitions() again for the flags we always need and use the
preferred way of selection the C++11 standard.
Hitesh Kanwathirtha 10 years ago
parent
commit
8ce3845c7c
2 changed files with 12 additions and 8 deletions
  1. 7 7
      CMakeLists.txt
  2. 5 1
      bin/GCStress/CMakeLists.txt

+ 7 - 7
CMakeLists.txt

@@ -65,17 +65,17 @@ if(CLR_CMAKE_PLATFORM_UNIX)
         -D_SAFECRT_USE_CPP_OVERLOADS=1
         )
 
+    add_compile_options(-fms-extensions)
+
+    # Disable some warnings
+    add_compile_options(-Wno-tautological-constant-out-of-range-compare)
+    set(CMAKE_CXX_STANDARD 11)
+
     # xplat-todo: enable the JIT for Linux
     add_definitions(
         -DDISABLE_JIT=1
         )
       
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fms-extensions")
-
-    # Disable some warnings
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-tautological-constant-out-of-range-compare")
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
-
     # xplat-todo: revisit these
     # also, we should change this from add_definitions- the intent of that
     # is to just add -D flags
@@ -133,4 +133,4 @@ include_directories(
     )
 add_subdirectory (lib)
 add_subdirectory (bin)
-add_subdirectory (pal)
+add_subdirectory (pal)

+ 5 - 1
bin/GCStress/CMakeLists.txt

@@ -13,7 +13,10 @@ target_include_directories (GCStress
   $<BUILD_INTERFACE:${ROOT_SOURCE_DIR}/lib/Common/Memory>  
   )
 
-set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -lsodium")
+find_library(SODIUM_PATH sodium)
+if (NOT SODIUM_PATH)
+  message(FATAL_ERROR "Sodium library is needed to build GCStress")
+endif (NOT SODIUM_PATH)
 
 target_link_libraries (GCStress
   PRIVATE Chakra.Common.Memory
@@ -22,5 +25,6 @@ target_link_libraries (GCStress
   PRIVATE Chakra.Common.DataStructures
   PRIVATE Chakra.Common.Exceptions
   PRIVATE Chakra.Pal
+  ${SODIUM_PATH}
   )