Skip to content

Commit

Permalink
Update CMake and CodeLite project: a bit verboce and more useful debu…
Browse files Browse the repository at this point in the history
…g build type
  • Loading branch information
rozhuk-im committed Jan 31, 2024
1 parent b41bc91 commit aa3fa09
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 40 deletions.
72 changes: 47 additions & 25 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}")

############################# OPTIONS SECTION ##########################

option(ENABLE_FULL_DEBUG "Build with all possible debug [default: OFF]" OFF)
option(ENABLE_ALSA "Enable ALSA mixer backend [default: AUTO]" OFF)
option(ENABLE_OSS "Enable OSSv3 mixer backend [default: AUTO]" OFF)

Expand Down Expand Up @@ -115,6 +114,7 @@ endif()

# Plugins specific.
if (ENABLE_ALSA)
message(STATUS "Plugin: ALSA")
find_package(ALSA REQUIRED)
if (ALSA_FOUND)
add_definitions(-DHAVE_ALSA)
Expand All @@ -124,6 +124,7 @@ if (ENABLE_ALSA)
endif()

if (ENABLE_OSS)
message(STATUS "Plugin: OSS")
find_package(OSS REQUIRED)
if (OSS_FOUND)
add_definitions(-DHAVE_OSS)
Expand All @@ -138,24 +139,54 @@ endif()
try_c_flag(PIPE "-pipe")
try_c_flag(NO_DEL_NULL_PTR_CHKS "-fno-delete-null-pointer-checks")

# Process with warn flags.
if (NOT CMAKE_C_OPT_FLAGS AND ENABLE_FULL_DEBUG)

if (CMAKE_BUILD_TYPE MATCHES "Debug")
# Process with warn flags.
try_c_flag(W "-W")
try_c_flag(WALL "-Wall")
try_c_flag(WPOINTER "-Wpointer-arith")
try_c_flag(WPARAM "-Wno-unused-parameter")
try_c_flag(WFUNCTION "-Wno-unused-function")
try_c_flag(WUNUSED_VAR "-Wno-unused-variable")
try_c_flag(WPOINTER_SIGN "-Wno-pointer-sign")
try_c_flag(WSIGN_COMPARE "-Wno-sign-compare")
try_c_flag(WSTRICT_PROTOTYPES "-Wstrict-prototypes")
try_c_flag(PEDANTIC "-pedantic")
try_c_flag(WNO_UNUSED_CONST "-Wno-unused-const-variable")
try_c_flag(WNULL_DEREFERENCE "-Wnull-dereference")
try_c_flag(WDUPLICATED_COND "-Wduplicated-cond")
try_c_flag(WIMPLICIT_FALLTHROUGH "-Wimplicit-fallthrough")
try_c_flag(WEVERYTHING "-Weverything")
if (NOT C_FLAG_WEVERYTHING)
try_c_flag(WPOINTER "-Wpointer-arith")
try_c_flag(WSTRICT_PROTOTYPES "-Wstrict-prototypes")
try_c_flag(PEDANTIC "-pedantic")
try_c_flag(WNULL_DEREFERENCE "-Wnull-dereference")
try_c_flag(WDUPLICATED_COND "-Wduplicated-cond")
try_c_flag(WIMPLICIT_FALLTHROUGH "-Wimplicit-fallthrough")
endif()

try_c_flag(WCAST_FN_TYPE_STRICT "-Wno-cast-function-type-strict")
try_c_flag(WCAST_QUAL "-Wno-cast-qual")
try_c_flag(WDOCUMENTATION "-Wno-documentation")
try_c_flag(WDOC_UNKNOWN_CMD "-Wno-documentation-unknown-command")
try_c_flag(WPADDED "-Wno-padded")
#try_c_flag(WPOINTER_SIGN "-Wno-pointer-sign")
#try_c_flag(WRESERVED_ID_MACRO "-Wno-reserved-id-macro")
try_c_flag(WRESERVED_IDENTIFIER "-Wno-reserved-identifier")
#try_c_flag(WSIGN_COMPARE "-Wno-sign-compare")
try_c_flag(WSWITCH_ENUM "-Wno-switch-enum")
#try_c_flag(WUNUSED_CONST "-Wno-unused-const-variable")
#try_c_flag(WUNUSED_FUNCTION "-Wno-unused-function")
#try_c_flag(WUNUSED_PARAM "-Wno-unused-parameter")
#try_c_flag(WUNUSED_VAR "-Wno-unused-variable")
try_c_flag(WUNSAFE_BUFFER_USAGE "-Wno-unsafe-buffer-usage")
#try_c_flag(WVARIADIC_MACROS "-Wno-variadic-macros")
#try_c_flag(WGNU_ZERO_VAR_MACRO_ARGS "-Wno-gnu-zero-variadic-macro-arguments")
try_c_flag(WZERO_LENGTH_ARRAY "-Wno-zero-length-array")

set(CMAKE_INSTALL_DO_STRIP FALSE)
set(CMAKE_C_OPT_FLAGS "-g3 -ggdb -O0")
message(STATUS "Adding -DDEBUG to definitions.")
add_definitions(-DDEBUG)
else()
set(CMAKE_INSTALL_DO_STRIP TRUE)
message(STATUS "Adding -DNDEBUG to definitions.")
add_definitions(-DNDEBUG)
endif()

message(STATUS "Building in ${CMAKE_BUILD_TYPE} mode.")
message(STATUS "CMAKE_INSTALL_DO_STRIP is ${CMAKE_INSTALL_DO_STRIP}.")


if (NOT "${CMAKE_C_COMPILER_ID}" MATCHES SunPro)
try_c_flag(STD11 "-std=c11")
if (NOT C_FLAG_STD11)
Expand Down Expand Up @@ -183,20 +214,11 @@ try_linker_flag(ZNOW "-Wl,-z,now")
try_linker_flag(ZNOEXECSTACK "-Wl,-z,noexecstack")


# Optimization flags
if (NOT CMAKE_C_OPT_FLAGS)
if (ENABLE_FULL_DEBUG)
set(CMAKE_C_OPT_FLAGS "-g -O0 -fstrict-aliasing")
else()
set(CMAKE_C_OPT_FLAGS "-g -O2 -fstrict-aliasing")
endif()
endif()


# Check platform API.
chk_function_exists(reallocarray)

set(CMAKE_C_FLAGS "${CMAKE_C_OPT_FLAGS} ${CMAKE_C_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_OPT_FLAGS}")
# Silently strip whitespace
string(STRIP "${CMAKE_C_FLAGS}" CMAKE_C_FLAGS)
string(STRIP "${CMAKE_EXE_LINKER_FLAGS}" CMAKE_EXE_LINKER_FLAGS)
Expand Down
41 changes: 26 additions & 15 deletions gtk-mixer.project
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@
<ResourceCompiler Options=""/>
</GlobalSettings>
<Configuration Name="Debug" CompilerType="clang" DebuggerType="GNU gdb debugger" Type="Executable" BuildCmpWithGlobalSettings="append" BuildLnkWithGlobalSettings="append" BuildResWithGlobalSettings="append">
<Compiler Options="-g;-O0;-Wall" C_Options="-Weverything;-ftrapv;-g -DDEBUG;-O0;-fwrapv;-fstack-protector-all;-Wall;-g3 -ggdb;-Wno-reserved-id-macro;-Wno-gnu-zero-variadic-macro-arguments;-Wno-variadic-macros;-Wno-documentation;-Wno-documentation-unknown-command;-Wno-padded;-Wno-cast-qual" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" PCHFlags="" PCHFlagsPolicy="0"/>
<Compiler Options="-g;-O0;-Wall" C_Options="-ftrapv;-g -DDEBUG;-O0;-fwrapv;-fstack-protector-all;-Wall;-g3 -ggdb;-Wno-reserved-id-macro;-Wno-gnu-zero-variadic-macro-arguments;-Wno-variadic-macros;-Wno-documentation;-Wno-documentation-unknown-command;-Wno-padded;-Wno-cast-qual;-Wno-cast-function-type-strict;-Wno-reserved-identifier;-Wno-unsafe-buffer-usage" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" PCHFlags="" PCHFlagsPolicy="0"/>
<Linker Options="" Required="yes"/>
<ResourceCompiler Options="" Required="no"/>
<General OutputFile="$(IntermediateDirectory)/$(ProjectName)" IntermediateDirectory="$(ProjectPath)/build/src/" Command="$(OutputFile)" CommandArguments="--start-hidden" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/>
<BuildSystem Name="Default"/>
<General OutputFile="$(IntermediateDirectory)/src/$(ProjectName)" IntermediateDirectory="$(ProjectPath)/$(ConfigurationName)" Command="$(OutputFile)" CommandArguments="--start-hidden" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/>
<BuildSystem Name="CodeLite Makefile Generator"/>
<Environment EnvVarSetName="&lt;Use Defaults&gt;" DbgSetName="&lt;Use Defaults&gt;">
<![CDATA[]]>
</Environment>
Expand All @@ -55,15 +55,25 @@
</Debugger>
<PreBuild/>
<PostBuild/>
<CustomBuild Enabled="no">
<RebuildCommand/>
<CleanCommand/>
<BuildCommand/>
<CustomBuild Enabled="yes">
<Target Name="Configure">mkdir $(ProjectPath)/$(ConfigurationName) &amp;&amp;
cd $(ProjectPath)/$(ConfigurationName) &amp;&amp;
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_VERBOSE_MAKEFILE=true -DENABLE_ALSA=true ..
</Target>
<RebuildCommand>rm -rf $(ProjectPath)/$(ConfigurationName) &amp;&amp;
mkdir $(ProjectPath)/$(ConfigurationName) &amp;&amp;
cd $(ProjectPath)/$(ConfigurationName) &amp;&amp;
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_VERBOSE_MAKEFILE=true -DENABLE_ALSA=true .. &amp;&amp;
make -C $(ProjectPath)/$(ConfigurationName) -j`getconf NPROCESSORS_ONLN`
</RebuildCommand>
<CleanCommand>rm -rf $(ProjectPath)/$(ConfigurationName)</CleanCommand>
<BuildCommand>make -C $(ProjectPath)/$(ConfigurationName) -j`getconf NPROCESSORS_ONLN`
</BuildCommand>
<PreprocessFileCommand/>
<SingleFileCommand/>
<MakefileGenerationCommand/>
<ThirdPartyToolName>None</ThirdPartyToolName>
<WorkingDirectory/>
<WorkingDirectory>$(WorkspacePath)</WorkingDirectory>
</CustomBuild>
<AdditionalRules>
<CustomPostBuild/>
Expand All @@ -82,7 +92,7 @@
</Compiler>
<Linker Options="" Required="yes"/>
<ResourceCompiler Options="" Required="no"/>
<General OutputFile="$(IntermediateDirectory)/$(ProjectName)" IntermediateDirectory="$(ProjectPath)/build/src/" Command="$(OutputFile)" CommandArguments="" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/>
<General OutputFile="$(IntermediateDirectory)/src/$(ProjectName)" IntermediateDirectory="$(ProjectPath)/$(ConfigurationName)" Command="$(OutputFile)" CommandArguments="" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/>
<BuildSystem Name="Default"/>
<Environment EnvVarSetName="&lt;Use Defaults&gt;" DbgSetName="&lt;Use Defaults&gt;">
<![CDATA[]]>
Expand All @@ -95,13 +105,14 @@
<PreBuild/>
<PostBuild/>
<CustomBuild Enabled="yes">
<Target Name="Configure">mkdir $(ProjectPath)/$(ConfigurationName) &amp;&amp;
cd $(ProjectPath)/$(ConfigurationName) &amp;&amp;
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE=true ..

</Target>
<RebuildCommand/>
<CleanCommand>rm -rf build</CleanCommand>
<BuildCommand>mkdir build &amp;&amp;
cd build &amp;&amp;
cmake -D CMAKE_VERBOSE_MAKEFILE=true .. &amp;&amp;
cmake --build . -- -j`getconf NPROCESSORS_ONLN`
</BuildCommand>
<CleanCommand>rm -rf $(ProjectPath)/$(ConfigurationName)</CleanCommand>
<BuildCommand>make -C $(ProjectPath)/$(ConfigurationName) -j`getconf NPROCESSORS_ONLN`</BuildCommand>
<PreprocessFileCommand/>
<SingleFileCommand/>
<MakefileGenerationCommand/>
Expand Down

0 comments on commit aa3fa09

Please sign in to comment.