Skip to content

Commit

Permalink
CMakeLists.txt: Configure for compat oldest libstdc++
Browse files Browse the repository at this point in the history
CMakeLists.txt: Add -fno-stack-protector
ExecuteString: Fix parser
build.yml: Add paths-ignore README.md
  • Loading branch information
s1lentq committed Mar 16, 2021
1 parent 2e8bd9e commit ce0bfa1
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 28 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name: C/C++ CI
on:
push:
branches: [master]
paths-ignore:
- '**.md'

pull_request:
types: [opened, reopened, synchronize]
release:
Expand Down
4 changes: 2 additions & 2 deletions rehlds/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffunction-sections -fdata-sections")
if (DEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -O3 -ggdb")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3 -fno-stack-protector")
endif()

if (USE_INTEL_COMPILER)
Expand All @@ -40,7 +40,7 @@ else()
# Produce code optimized for the most common IA32/AMD64/EM64T processors.
# As new processors are deployed in the marketplace, the behavior of this option will change.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mtune=generic -msse3\
-fpermissive\
-fpermissive -fno-sized-deallocation\
-Wno-unknown-pragmas -Wno-invalid-offsetof\
-Wno-unused-variable -Wno-unused-result -Wno-unused-function -Wno-delete-non-virtual-dtor\
-Wno-write-strings -Wno-format\
Expand Down
11 changes: 7 additions & 4 deletions rehlds/HLTV/Console/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@ elseif (USE_CLANG_COMPILER)
set(CMAKE_CXX_COMPILER "/usr/bin/clang++")
endif()

set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-exceptions")

if (DEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -O3 -ggdb")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3 -fno-stack-protector")
endif()

set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -no-pie")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -no-pie -Wl,--no-export-dynamic")

if (USE_INTEL_COMPILER)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qoption,cpp,--treat_func_as_string_literal_cpp")
Expand All @@ -38,7 +41,7 @@ else()
# Produce code optimized for the most common IA32/AMD64/EM64T processors.
# As new processors are deployed in the marketplace, the behavior of this option will change.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mtune=generic -msse3 -flto\
-fpermissive\
-fpermissive -fno-sized-deallocation\
-Wno-unused-result -Wno-unknown-pragmas -Wno-write-strings")
endif()

Expand Down Expand Up @@ -96,5 +99,5 @@ endif()

add_executable(hltv ${appversion.sh} ${HLTV_SRCS} ${COMMON_SRCS})
target_link_libraries(hltv dl)
set_target_properties(hltv PROPERTIES PREFIX "" COMPILE_FLAGS "-m32" LINK_FLAGS "-m32" POSITION_INDEPENDENT_CODE ON)
set_target_properties(hltv PROPERTIES PREFIX "" COMPILE_FLAGS "-m32" LINK_FLAGS "-m32")
add_dependencies(hltv appversion)
8 changes: 4 additions & 4 deletions rehlds/HLTV/Console/src/System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,19 +173,19 @@ void System::ExecuteString(const char *commands)
unsigned int i;
for (i = 0; i < ARRAYSIZE(singleCmd); i++)
{
char c = *pszSource++;

*pszDest++ = c;
const char c = *pszSource++;

if (c == '"')
{
bInQuote = !bInQuote;
}
else if (c == ';' && !bInQuote)
else if ((c == ';' && !bInQuote) || !c)
{
// End of command and not in a quoted string
break;
}

*pszDest++ = c;
}

if (i >= ARRAYSIZE(singleCmd))
Expand Down
4 changes: 2 additions & 2 deletions rehlds/HLTV/Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-exceptions")
if (DEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -O3 -ggdb")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3 -fno-stack-protector")
endif()

if (USE_INTEL_COMPILER)
Expand All @@ -36,7 +36,7 @@ else()
# Produce code optimized for the most common IA32/AMD64/EM64T processors.
# As new processors are deployed in the marketplace, the behavior of this option will change.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mtune=generic -msse3 -flto\
-fpermissive\
-fpermissive -fno-sized-deallocation\
-Wno-unused-result -Wno-unknown-pragmas -Wno-unused-variable\
-Wno-sign-compare -Wno-write-strings -Wno-strict-aliasing")

Expand Down
4 changes: 2 additions & 2 deletions rehlds/HLTV/DemoPlayer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-exceptions")
if (DEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -O3 -ggdb")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3 -fno-stack-protector")
endif()

if (USE_INTEL_COMPILER)
Expand All @@ -36,7 +36,7 @@ else()
# Produce code optimized for the most common IA32/AMD64/EM64T processors.
# As new processors are deployed in the marketplace, the behavior of this option will change.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mtune=generic -msse3 -flto\
-fpermissive\
-fpermissive -fno-sized-deallocation\
-Wno-unused-result -Wno-unknown-pragmas\
-Wno-sign-compare -Wno-write-strings -Wno-strict-aliasing")
endif()
Expand Down
4 changes: 2 additions & 2 deletions rehlds/HLTV/Director/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-exceptions")
if (DEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -O3 -ggdb")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3 -fno-stack-protector")
endif()

if (USE_INTEL_COMPILER)
Expand All @@ -36,7 +36,7 @@ else()
# Produce code optimized for the most common IA32/AMD64/EM64T processors.
# As new processors are deployed in the marketplace, the behavior of this option will change.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mtune=generic -msse3 -flto\
-fpermissive\
-fpermissive -fno-sized-deallocation\
-Wno-unused-result -Wno-unknown-pragmas\
-Wno-write-strings -Wno-strict-aliasing")
endif()
Expand Down
4 changes: 2 additions & 2 deletions rehlds/HLTV/Proxy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-exceptions")
if (DEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -O3 -ggdb")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3 -fno-stack-protector")
endif()

if (USE_INTEL_COMPILER)
Expand All @@ -36,7 +36,7 @@ else()
# Produce code optimized for the most common IA32/AMD64/EM64T processors.
# As new processors are deployed in the marketplace, the behavior of this option will change.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mtune=generic -msse3 -flto\
-fpermissive\
-fpermissive -fno-sized-deallocation\
-Wno-unused-result -Wno-unknown-pragmas -Wno-unused-variable\
-Wno-write-strings -Wno-strict-aliasing")

Expand Down
11 changes: 7 additions & 4 deletions rehlds/dedicated/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@ elseif (USE_CLANG_COMPILER)
set(CMAKE_CXX_COMPILER "/usr/bin/clang++")
endif()

set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-exceptions")

if (DEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -O3 -ggdb")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3 -fno-stack-protector")
endif()

set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -no-pie")
set(CMAKE_EXE_LINKER_FLAGS "-no-pie -Wl,--no-export-dynamic")

if (USE_INTEL_COMPILER)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qoption,cpp,--treat_func_as_string_literal_cpp")
Expand All @@ -38,7 +41,7 @@ else()
# Produce code optimized for the most common IA32/AMD64/EM64T processors.
# As new processors are deployed in the marketplace, the behavior of this option will change.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mtune=generic -msse3 -flto\
-fpermissive\
-fpermissive -fno-sized-deallocation\
-Wno-unused-result")
endif()

Expand Down Expand Up @@ -92,4 +95,4 @@ add_definitions(

add_executable(hlds ${DEDICATED_SRCS} ${COMMON_SRCS})
target_link_libraries(hlds dl)
set_target_properties(hlds PROPERTIES OUTPUT_NAME hlds_linux PREFIX "" COMPILE_FLAGS "-m32" LINK_FLAGS "-m32" POSITION_INDEPENDENT_CODE ON)
set_target_properties(hlds PROPERTIES OUTPUT_NAME hlds_linux PREFIX "" COMPILE_FLAGS "-m32" LINK_FLAGS "-m32")
8 changes: 4 additions & 4 deletions rehlds/engine/SystemWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,19 +572,19 @@ void SystemWrapper::ExecuteString(const char *commands)
unsigned int i;
for (i = 0; i < ARRAYSIZE(singleCmd); i++)
{
char c = *pszSource++;

*pszDest++ = c;
const char c = *pszSource++;

if (c == '"')
{
bInQuote = !bInQuote;
}
else if (c == ';' && !bInQuote)
else if ((c == ';' && !bInQuote) || !c)
{
// End of command and not in a quoted string
break;
}

*pszDest++ = c;
}

if (i >= ARRAYSIZE(singleCmd))
Expand Down
4 changes: 2 additions & 2 deletions rehlds/filesystem/FileSystem_Stdio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-exceptions")
if (DEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -O3 -ggdb")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3 -fno-stack-protector")
endif()

if (USE_INTEL_COMPILER)
Expand All @@ -38,7 +38,7 @@ else()
# Produce code optimized for the most common IA32/AMD64/EM64T processors.
# As new processors are deployed in the marketplace, the behavior of this option will change.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mtune=generic -msse3\
-fpermissive\
-fpermissive -fno-sized-deallocation\
-Wno-unknown-pragmas -Wno-unused-result -Wno-unused-variable -Wno-unused-function\
-Wno-write-strings -Wno-sign-compare")

Expand Down

0 comments on commit ce0bfa1

Please sign in to comment.