aboutsummaryrefslogtreecommitdiff
path: root/src/CmakeModule.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/CmakeModule.cpp')
-rw-r--r--src/CmakeModule.cpp35
1 files changed, 28 insertions, 7 deletions
diff --git a/src/CmakeModule.cpp b/src/CmakeModule.cpp
index a706e64..62aaf34 100644
--- a/src/CmakeModule.cpp
+++ b/src/CmakeModule.cpp
@@ -194,11 +194,25 @@ namespace sibs
_putenv("CXXFLAGS=-fPIC");
#endif
#endif
+
std::vector<FileString> cmd = { cmakePath };
FileString cflags = TINYDIR_STRING("-fPIC");
FileString cxxflags;
+ // TODO: msvc
+ if(config.getCompiler() == Compiler::GCC || config.getCompiler() == Compiler::MINGW_W64)
+ {
+ switch(config.cpu) {
+ case sibs::CPU_INVALID:
+ case sibs::CPU_BASELINE:
+ break;
+ case sibs::CPU_NATIVE:
+ cflags += TINYDIR_STRING(" -march=native");
+ break;
+ }
+ }
+
if(config.getCompiler() == Compiler::GCC || config.getCompiler() == Compiler::MINGW_W64)
{
cflags += TINYDIR_STRING(" -fno-omit-frame-pointer");
@@ -238,6 +252,11 @@ namespace sibs
}
}
+ if(config.linker == "mold")
+ cflags += TINYDIR_STRING(" -B/usr/lib/mold/");
+ else if(!config.linker.empty())
+ cflags += TINYDIR_STRING(" -fuse-ld=") + toFileString(config.linker);
+
cxxflags = cflags;
cmd.push_back(TINYDIR_STRING("-DCMAKE_C_FLAGS=") + cflags);
cmd.push_back(TINYDIR_STRING("-DCMAKE_CXX_FLAGS=") + cxxflags);
@@ -299,14 +318,16 @@ namespace sibs
return Result<bool>::Err(execResult);
//nprintf("Compiling cmake generated ninja file: %s\n", buildPath.c_str());
- execResult = exec({ TINYDIR_STRING("ninja"), TINYDIR_STRING("-C"), buildPath }, true);
- if(execResult.isOk())
- {
- if(execResult.unwrap().exitCode != 0)
- return Result<bool>::Err(execResult.unwrap().execStdout);
+ if(!config.skipCompile) {
+ execResult = exec({ TINYDIR_STRING("ninja"), TINYDIR_STRING("-C"), buildPath }, true);
+ if(execResult.isOk())
+ {
+ if(execResult.unwrap().exitCode != 0)
+ return Result<bool>::Err(execResult.unwrap().execStdout);
+ }
+ else
+ return Result<bool>::Err(execResult);
}
- else
- return Result<bool>::Err(execResult);
if(config.getPackageType() != PackageType::EXECUTABLE)
{