I have the following conan profile:
$ conan profile show default
Configuration for profile default:
[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=gcc
compiler.version=11
compiler.cppstd=20
compiler.libcxx=libstdc++
build_type=Release
[options]
[conf]
[build_requires]
[env]
Note that compiler.libcxx is the old ABI (libstdc++) and not the new ABI (libstdc++11). This is intentional. Also I'm specifying cppstd=20.
I then made a custom conanfile for {fmt}, which tries to package up fmt 9.0. That looks like, in its entirety:
from conans import ConanFile, CMake, tools
from conan.tools.cmake import CMakeToolchain, cmake_layout
class ConanFmt(ConanFile):
name = "fmt"
version = "9.0.0"
settings = "os", "compiler", "cppstd", "build_type", "arch"
def source(self):
git = tools.Git(folder="fmt")
git.clone("https://github.com/fmtlib/fmt.git", "9.0.0", shallow=True)
def layout(self):
cmake_layout(self)
def generate(self):
tc = CMakeToolchain(self)
tc.generate()
def build(self):
cmake = CMake(self)
cmake.definitions["FMT_DOC"] = False
cmake.definitions["FMT_TEST"] = False
cmake.definitions["FMT_INSTALL"] = True
cmake.definitions["CMAKE_EXPORT_COMPILE_COMMANDS"] = True
cmake.configure(source_folder="fmt")
cmake.build()
def package(self):
cmake = CMake(self)
cmake.install()
def package_info(self):
self.cpp_info.libs = ["fmt"]
When I try to go ahead and package this up, like say:
$ conan create . demo/testing -s build_type=Release
This does actually go ahead and clone the {fmt} repo, and correctly build and package up the contents of the library.
Except that:
there is no _GLIBCXX_USE_CXX11_ABI definition set (despite what this page) says.
{fmt} was compiled with C++11, not C++20
... but it was built with Release (-O3 -DNDEBUG)
Conan does appear to provide variables like CONAN_CMAKE_CXX_STANDARD=20, CONAN_STD_CXX_FLAG=-std=c++2a, and CONAN_LIBCXX=libstdc++. But {fmt}'s build doesn't actually use those, so that isn't very useful.
How do I actually get conan to propagate through these fields properly? Is that something that must be explicitly specified in the conanfile.py (even if it's in the profile)?
Related
I've been trying now to install grpc (C++) via bazel and cmake.. both have failures.. BUT i thought to myself give conan a try.. but there's an error about protobuf.. so I added it to the requirements and yet it's not helping.. any ideas?
Conanfile.py
from conans import ConanFile, CMake, tools
GRPC_VERSION = "v1.48.0"
class GRPCExample(ConanFile):
name = "grpc-example"
version = GRPC_VERSION
url = "https://github.com/grpc/grpc"
description = "Built from grpcs example code in Github"
topics = ("grpc", "example")
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False]}
default_options = {"shared": False}
generators = "cmake"
requires = [("protobuf/3.21.4")]
def source(self):
self.run("git clone --depth 1 --branch " + GRPC_VERSION + " https://github.com/grpc/grpc")
def build(self):
cmake = CMake(self)
cmake.configure(source_folder="grpc/examples/cpp/helloworld")
cmake.build()
def package(self):
self.copy("*.h", dst="include", src="grpc/examples/cpp/helloworld")
self.copy("*.lib", dst="lib", keep_path=False)
self.copy("*.dll", dst="bin", keep_path=False)
self.copy("*.so", dst="lib", keep_path=False)
self.copy("*.dylib", dst="lib", keep_path=False)
self.copy("*.a", dst="lib", keep_path=False)
def package_info(self):
self.cpp_info.libs = ["grpc-example"]
-- Found Threads: TRUE
CMake Error at /home/emcp/.conan/data/grpc-example/v1.48.0/stonks/dev/build/1df012f840559ffd3600baf4353bf1a2db1635ac/grpc/examples/cpp/cmake/common.cmake:101 (find_package):
Could not find a package configuration file provided by "Protobuf" with any
of the following names:
ProtobufConfig.cmake
protobuf-config.cmake
Add the installation prefix of "Protobuf" to CMAKE_PREFIX_PATH or set
"Protobuf_DIR" to a directory containing one of the above files. If
"Protobuf" provides a separate development package or SDK, be sure it has
been installed.
Call Stack (most recent call first):
CMakeLists.txt:24 (include)
-- Configuring incomplete, errors occurred!
See also "/home/emcp/.conan/data/grpc-example/v1.48.0/stonks/dev/build/1df012f840559ffd3600baf4353bf1a2db1635ac/CMakeFiles/CMakeOutput.log".
grpc-example/v1.48.0#stonks/dev:
grpc-example/v1.48.0#stonks/dev: ERROR: Package '1df012f840559ffd3600baf4353bf1a2db1635ac' build failed
grpc-example/v1.48.0#stonks/dev: WARN: Build folder /home/emcp/.conan/data/grpc-example/v1.48.0/stonks/dev/build/1df012f840559ffd3600baf4353bf1a2db1635ac
ERROR: grpc-example/v1.48.0#stonks/dev: Error in build() method, line 25
cmake.configure(source_folder="grpc/examples/cpp/helloworld")
ConanException: Error 1 while executing cd '/home/emcp/.conan/data/grpc-example/v1.48.0/stonks/dev/build/1df012f840559ffd3600baf4353bf1a2db1635ac' && cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE="Release" -DCONAN_IN_LOCAL_CACHE="ON" -DCONAN_COMPILER="gcc" -DCONAN_COMPILER_VERSION="11" -DCONAN_CXX_FLAGS="-m64" -DCONAN_SHARED_LINKER_FLAGS="-m64" -DCONAN_C_FLAGS="-m64" -DCONAN_LIBCXX="libstdc++11" -DBUILD_SHARED_LIBS="OFF" -DCMAKE_INSTALL_PREFIX="/home/emcp/.conan/data/grpc-example/v1.48.0/stonks/dev/package/1df012f840559ffd3600baf4353bf1a2db1635ac" -DCMAKE_INSTALL_BINDIR="bin" -DCMAKE_INSTALL_SBINDIR="bin" -DCMAKE_INSTALL_LIBEXECDIR="bin" -DCMAKE_INSTALL_LIBDIR="lib" -DCMAKE_INSTALL_INCLUDEDIR="include" -DCMAKE_INSTALL_OLDINCLUDEDIR="include" -DCMAKE_INSTALL_DATAROOTDIR="share" -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" -Wno-dev '/home/emcp/.conan/data/grpc-example/v1.48.0/stonks/dev/build/1df012f840559ffd3600baf4353bf1a2db1635ac/grpc/examples/cpp/helloworld'
This question already has answers here:
How to link to the C math library with CMake?
(3 answers)
How do I add a linker or compile flag in a CMake file?
(7 answers)
Closed 9 months ago.
I am using the modern conan method for compiling. I am cross compiling an application and am trying to figure out how to convert my existing gcc command to conan / cmake solution.
Here is the gcc command:
arm-linux-gnueabihf-gcc -Wall -static -o sctc sctc.cpp -lm -lstdc++
Pretty simple.
I have successfully built the application using conan/cmake. However it is not running, I think because I am unable to invoke add the options:
-static
-lm
-lstdc++
I think. Also, would like to know how to add -Wall.
How are people debugging the command lines? Any docs or blogs about it?
Here is the conanfile.py
from conans import ConanFile, tools
from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps
import os
class SctsConan(ConanFile):
name = "sctc"
version = "1.0.0"
license = "<Put the package license here>"
author = "<Put your name here> <And your email here>"
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = {"shared": False, "fPIC": True}
generators = "compiler_args"
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
def requirements(self):
self.requires("fff/1.1")
self.requires("gtest/cci.20210126")
def generate(self):
tc = CMakeToolchain(self)
tc.generate()
deps = CMakeDeps(self)
deps.generate()
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def package_info(self):
self.cpp_info.libs = ["sctc"]
Here is the profile
[settings]
os=Linux
compiler=gcc
compiler.version=9.4
compiler.libcxx=libstdc++11
build_type=Release
arch=armv6
[env]
CC=arm-linux-gnueabihf-gcc
CXX=arm-linux-gnueabihf-g++-9
Here is the CMakeFile.txt
cmake_minimum_required(VERSION 3.14)
project(sctc)
add_executable(sctc sctc.cpp )
Any pointers to documentation are welcome. I tried searching for answers but was not able to find anything that I thought relevant. I am new to conan and cmake but am enjoying working with both.
Cheers,
Dave
I am want to package a CMake project with conan.
For that I use the following conanfile.py:
import os
from conans import ConanFile, tools
from conan.tools.cmake import CMake, CMakeToolchain
from conans.tools import Version
class BaseLibrary(ConanFile):
name = "base-library"
version = "1.0.0"
description = """This is a test project with a library base::io
and base::math and an executable cli."""
license = "MIT"
generators = "cmake_find_package_multi", "cmake_find_package",
default_options = {"fmt:shared": True}
build_policy = "missing" # if this package is build by default if missing.
settings = "os", "compiler", "build_type", "arch"
exports_sources = "*"
_cmake = None
def requirements(self):
if Version(self.version) >= "1.0.0":
self.requires("fmt/8.0.1")
def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.configure(source_folder=".")
return self._cmake
def build(self):
cmake = self._configure_cmake()
cmake.build()
cmake.install()
def package(self):
cmake = self._configure_cmake()
cmake.install()
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
tools.rmdir(os.path.join(self.package_folder, "share"))
def package_info(self):
self.cpp_info.names["cmake_find_package"] = "base"
self.cpp_info.names["cmake_find_package_multi"] = "base"
self.cpp_info.names["pkg_config"] = "base"
which is next to my main CMakeLists.txt file. The CMake project builds without problems and also has a proper install target which installs everything properly: bin,lib,include,share. In CMake I use the conan-cmake module with basically something like this.
When I run
conan create -s build_type=Release . demo/testing
I get the following weird error:
...
Requirements
base-library/1.0.0#demo/testing from local cache - Cache
fmt/8.0.1 from 'conancenter' - Cache
Packages
base-library/1.0.0#demo/testing:4f2b14d304ab8e4391d162a6eb44110cc27a3faa - Build
fmt/8.0.1:d4e9c4f02b4f03edf5a640dcd22779727d782e79 - Cache
Installing (downloading, building) binaries...
fmt/8.0.1: Already installed!
base-library/1.0.0#demo/testing: WARN: Build folder is dirty, removing it: /home/developer/.conan/data/base-library/1.0.0/demo/testing/build/4f2b14d304ab8e4391d162a6eb44110cc27a3faa
base-library/1.0.0#demo/testing: Configuring sources in /home/developer/.conan/data/base-library/1.0.0/demo/testing/source
base-library/1.0.0#demo/testing: Copying sources to build folder
base-library/1.0.0#demo/testing: Building your package in /home/developer/.conan/data/base-library/1.0.0/demo/testing/build/4f2b14d304ab8e4391d162a6eb44110cc27a3faa
base-library/1.0.0#demo/testing: Generator cmake_find_package created Findfmt.cmake
base-library/1.0.0#demo/testing: Generator cmake_find_package_multi created fmt-config-version.cmake
base-library/1.0.0#demo/testing: Generator cmake_find_package_multi created fmt-config.cmake
base-library/1.0.0#demo/testing: Generator cmake_find_package_multi created fmtTargets.cmake
base-library/1.0.0#demo/testing: Generator cmake_find_package_multi created fmtTarget-release.cmake
base-library/1.0.0#demo/testing: Aggregating env generators
base-library/1.0.0#demo/testing: Calling build()
base-library/1.0.0#demo/testing:
base-library/1.0.0#demo/testing: ERROR: Package '4f2b14d304ab8e4391d162a6eb44110cc27a3faa' build failed
base-library/1.0.0#demo/testing: WARN: Build folder /home/developer/.conan/data/base-library/1.0.0/demo/testing/build/4f2b14d304ab8e4391d162a6eb44110cc27a3faa
ERROR: base-library/1.0.0#demo/testing: Error in build() method, line 74
cmake = self._configure_cmake()
while calling '_configure_cmake', line 65
self._cmake = CMake(self)
ConanException: The file /home/developer/.conan/data/base-library/1.0.0/demo/testing/build/4f2b14d304ab8e4391d162a6eb44110cc27a3faa/conanbuild.conf does not exist. Please, make sure that it was not generated in another folder.
What is the problem here and how can I resolve this? I could not find anything related to this?
from conans import ConanFile, CMake
...
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
...
I had the same problem and finally found the issue:
The CMake you are importing is the one working with the CMakeToolchain which are both part of the conan.tools.cmake module.
The one that is described in the usage of cmake_find_package[ref] is the one in conans module
So replacing:
from conans import ConanFile, tools
from conan.tools.cmake import CMake, CMakeToolchain
by
from conans import ConanFile, tools, CMake
from conan.tools.cmake import CMakeToolchain
should fix your problem
I implemented a MPC controller within CARLA 0.9.8 trafficmanager. That MPC controller is dependent on IPOPT.
Carla make commands (make rebuild; make PythonAPI) work fine.
However import carla in the python script spawn_npc.py throws the following error:
ImportError: /home/DNDE.EMEA.DENSO/cha/.cache/Python-Eggs/carla-0.9.8-py2.7-linux-x86_64.egg-tmp/carla/libcarla.so: undefined symbol: _ZN5Ipopt16IpoptApplicationC1Ebb
After googling for hours I assume that I have to modify the file setup.py in order to include and link the ipopt library, which is in /usr/local/lib.
But my trial & error procedure was not successful
The setup.py file is:
#!/usr/bin/env python
# Copyright (c) 2019 Computer Vision Center (CVC) at the Universitat Autonoma de
# Barcelona (UAB).
#
# This work is licensed under the terms of the MIT license.
# For a copy, see <https://opensource.org/licenses/MIT>.
from setuptools import setup, Extension
import fnmatch
import os
import platform
import sys
def get_libcarla_extensions():
include_dirs = ['dependencies/include']
library_dirs = ['dependencies/lib']
libraries = []
sources = ['source/libcarla/libcarla.cpp']
def walk(folder, file_filter='*'):
for root, _, filenames in os.walk(folder):
for filename in fnmatch.filter(filenames, file_filter):
yield os.path.join(root, filename)
if os.name == "posix":
# #todo Replace deprecated method.
linux_distro = platform.dist()[0] # pylint: disable=W1505
if linux_distro.lower() in ["ubuntu", "debian", "deepin"]:
pwd = os.path.dirname(os.path.realpath(__file__))
pylib = "libboost_python%d%d.a" % (sys.version_info.major,
sys.version_info.minor)
extra_link_args = [
os.path.join(pwd, 'dependencies/lib/libcarla_client.a'),
os.path.join(pwd, 'dependencies/lib/librpc.a'),
os.path.join(pwd, 'dependencies/lib/libboost_filesystem.a'),
os.path.join(pwd, 'dependencies/lib/libRecast.a'),
os.path.join(pwd, 'dependencies/lib/libDetour.a'),
os.path.join(pwd, 'dependencies/lib/libDetourCrowd.a'),
os.path.join(pwd, 'dependencies/lib', pylib)]
extra_compile_args = [
'-isystem', 'dependencies/include/system', '-fPIC', '-std=c++14',
'-Werror', '-Wall', '-Wextra', '-Wpedantic', '-Wno-self-assign-overloaded',
'-Wdeprecated', '-Wno-shadow', '-Wuninitialized', '-Wunreachable-code',
'-Wpessimizing-move', '-Wold-style-cast', '-Wnull-dereference',
'-Wduplicate-enum', '-Wnon-virtual-dtor', '-Wheader-hygiene',
'-Wconversion', '-Wfloat-overflow-conversion',
'-DBOOST_ERROR_CODE_HEADER_ONLY', '-DLIBCARLA_WITH_PYTHON_SUPPORT'
]
if 'BUILD_RSS_VARIANT' in os.environ and os.environ['BUILD_RSS_VARIANT'] == 'true':
print('Building AD RSS variant.')
extra_compile_args += ['-DLIBCARLA_RSS_ENABLED']
extra_link_args += [os.path.join(pwd, 'dependencies/lib/libad-rss.a')]
if 'TRAVIS' in os.environ and os.environ['TRAVIS'] == 'true':
print('Travis CI build detected: disabling PNG support.')
extra_link_args += ['-ljpeg', '-ltiff']
extra_compile_args += ['-DLIBCARLA_IMAGE_WITH_PNG_SUPPORT=false']
else:
extra_link_args += ['-lpng', '-ljpeg', '-ltiff']
extra_compile_args += ['-DLIBCARLA_IMAGE_WITH_PNG_SUPPORT=true']
# #todo Why would we need this?
include_dirs += ['/usr/lib/gcc/x86_64-linux-gnu/7/include']
library_dirs += ['/usr/lib/gcc/x86_64-linux-gnu/7']
extra_link_args += ['/usr/lib/gcc/x86_64-linux-gnu/7/libstdc++.a']
else:
raise NotImplementedError
elif os.name == "nt":
sources += [x for x in walk('dependencies/include/carla', '*.cpp')]
pwd = os.path.dirname(os.path.realpath(__file__))
pylib = 'libboost_python%d%d' % (
sys.version_info.major,
sys.version_info.minor)
extra_link_args = ['shlwapi.lib' ]
required_libs = [
pylib, 'libboost_filesystem',
'rpc.lib', 'carla_client.lib',
'libpng.lib', 'zlib.lib',
'Recast.lib', 'Detour.lib', 'DetourCrowd.lib']
# Search for files in 'PythonAPI\carla\dependencies\lib' that contains
# the names listed in required_libs in it's file name
libs = [x for x in os.listdir('dependencies/lib') if any(d in x for d in required_libs)]
for lib in libs:
extra_link_args.append(os.path.join(pwd, 'dependencies/lib', lib))
# https://learn.microsoft.com/es-es/cpp/porting/modifying-winver-and-win32-winnt
extra_compile_args = [
'/experimental:external', '/external:I', 'dependencies/include/system',
'/DBOOST_ALL_NO_LIB', '/DBOOST_PYTHON_STATIC_LIB',
'/DBOOST_ERROR_CODE_HEADER_ONLY', '/D_WIN32_WINNT=0x0600', '/DHAVE_SNPRINTF',
'/DLIBCARLA_WITH_PYTHON_SUPPORT', '-DLIBCARLA_IMAGE_WITH_PNG_SUPPORT=true']
else:
raise NotImplementedError
depends = [x for x in walk('source/libcarla')]
depends += [x for x in walk('dependencies')]
def make_extension(name, sources):
return Extension(
name,
sources=sources,
include_dirs=include_dirs,
library_dirs=library_dirs,
libraries=libraries,
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
language='c++14',
depends=depends)
print('compiling:\n - %s' % '\n - '.join(sources))
return [make_extension('carla.libcarla', sources)]
setup(
name='carla',
version='0.9.8',
package_dir={'': 'source'},
packages=['carla'],
ext_modules=get_libcarla_extensions(),
license='MIT License',
description='Python API for communicating with the CARLA server.',
url='https://github.com/carla-simulator/carla',
author='The CARLA team',
author_email='carla.simulator#gmail.com',
include_package_data=True)
includes in MPC.cpp:
#include "carla/trafficmanager/MPC.h"
#include <cppad/cppad.hpp>
#include <cppad/ipopt/solve.hpp>
#include <Eigen-3.3/Eigen/Dense>
includes in MPC.h:
#include <vector>
#include <Eigen-3.3/Eigen/Dense>
#include "carla/trafficmanager/PIDController.h"
#include "carla/client/Vehicle.h"
#include "carla/geom/Math.h"
Can anyone help?
The setup script calls the compiler to generate a shared library. Just modify the extra_link_args to link your library as you would do if you were calling the compiler directly.
Assuming you're using Linux, if you have your library installed in your machine add a -lipopt, in the same way is done with -lpng for libpng. If you have it somewhere not on your system libraries path or want to link statically pass the full path, just as it's done for libcarla_client.a for instance.
Carla uses clang as compiler on Linux, you can check its command-line ref if you want more details.
The recent version of carla was throwing the same error for me after researching for some time ,I have tried this method hope it works for you. First go to the location of the spawn.py folder using command prompt and type the following commands.
py -3.7 spawn.py
It supports only 3.7 version of python .You can refer youtube to understand how to run keep multiple version of python in windows.
Good afternoon.
I have a build script in Scons:
EnsureSConsVersion(0,14);
import string
import os
import os.path
import glob
import sys
import methods
methods.update_version()
# scan possible build platforms
platform_list = [] # list of platforms
platform_opts = {} # options for each platform
platform_flags = {} # flags for each platform
active_platforms=[]
active_platform_ids=[]
platform_exporters=[]
global_defaults=[]
for x in glob.glob("platform/*"):
if (not os.path.isdir(x)):
continue
tmppath="./"+x
sys.path.append(tmppath)
import detect
if (os.path.exists(x+"/export/export.cpp")):
platform_exporters.append(x[9:])
if (os.path.exists(x+"/globals/global_defaults.cpp")):
global_defaults.append(x[9:])
if (detect.is_active()):
active_platforms.append( detect.get_name() )
active_platform_ids.append(x);
if (detect.can_build()):
x=x.replace("platform/","") # rest of world
x=x.replace("platform\\","") # win32
platform_list+=[x]
platform_opts[x]=detect.get_opts()
platform_flags[x]=detect.get_flags()
sys.path.remove(tmppath)
sys.modules.pop('detect')
module_list=methods.detect_modules()
print "Detected Platforms: "+str(platform_list)
print("Detected Modules: "+str(module_list))
methods.save_active_platforms(active_platforms,active_platform_ids)
custom_tools=['default']
if (os.name=="posix"):
pass
elif (os.name=="nt"):
if (os.getenv("VSINSTALLDIR")==None):
custom_tools=['mingw']
env_base=Environment(tools=custom_tools,ENV = {'PATH' : os.environ['PATH']});
#env_base=Environment(tools=custom_tools);
env_base.global_defaults=global_defaults
env_base.android_source_modules=[]
env_base.android_source_files=[]
env_base.android_module_libraries=[]
env_base.android_manifest_chunk=""
env_base.disabled_modules=[]
env_base.__class__.android_module_source = methods.android_module_source
env_base.__class__.android_module_library = methods.android_module_library
env_base.__class__.android_module_file = methods.android_module_file
env_base.__class__.android_module_manifest = methods.android_module_manifest
env_base.__class__.disable_module = methods.disable_module
env_base.__class__.add_source_files = methods.add_source_files
customs = ['custom.py']
profile = ARGUMENTS.get("profile", False)
if profile:
import os.path
if os.path.isfile(profile):
customs.append(profile)
elif os.path.isfile(profile+".py"):
customs.append(profile+".py")
opts=Options(customs, ARGUMENTS)
opts.Add('target', 'Compile Target (debug/profile/release).', "debug")
opts.Add('platform','Platform: '+str(platform_list)+'(sfml).',"")
opts.Add('python','Build Python Support: (yes/no)','no')
opts.Add('squirrel','Build Squirrel Support: (yes/no)','no')
opts.Add('tools','Build Tools (Including Editor): (yes/no)','yes')
opts.Add('lua','Build Lua Support: (yes/no)','no')
opts.Add('rfd','Remote Filesystem Driver: (yes/no)','no')
opts.Add('gdscript','Build GDSCript support: (yes/no)','yes')
opts.Add('vorbis','Build Ogg Vorbis Support: (yes/no)','yes')
opts.Add('minizip','Build Minizip Archive Support: (yes/no)','yes')
opts.Add('opengl', 'Build OpenGL Support: (yes/no)', 'yes')
opts.Add('game', 'Game (custom) Code Directory', "")
opts.Add('squish','Squish BC Texture Compression (yes/no)','yes')
opts.Add('theora','Theora Video (yes/no)','yes')
opts.Add('freetype','Freetype support in editor','yes')
opts.Add('speex','Speex Audio (yes/no)','yes')
opts.Add('xml','XML Save/Load support (yes/no)','yes')
opts.Add('png','PNG Image loader support (yes/no)','yes')
opts.Add('jpg','JPG Image loader support (yes/no)','yes')
opts.Add('webp','WEBP Image loader support (yes/no)','yes')
opts.Add('dds','DDS Texture loader support (yes/no)','yes')
opts.Add('pvr','PVR (PowerVR) Texture loader support (yes/no)','yes')
opts.Add('builtin_zlib','Use built-in zlib (yes/no)','yes')
opts.Add('musepack','Musepack Audio (yes/no)','yes')
opts.Add('default_gui_theme','Default GUI theme (yes/no)','yes')
opts.Add("CXX", "Compiler");
opts.Add("nedmalloc", "Add nedmalloc support", 'yes');
opts.Add("CCFLAGS", "Custom flags for the C++ compiler");
opts.Add("CFLAGS", "Custom flags for the C compiler");
opts.Add("LINKFLAGS", "Custom flags for the linker");
opts.Add('disable_3d', 'Disable 3D nodes for smaller executable (yes/no)', "no")
opts.Add('disable_advanced_gui', 'Disable advance 3D gui nodes and behaviors (yes/no)', "no")
opts.Add('old_scenes', 'Compatibility with old-style scenes', "yes")
# add platform specific options
for k in platform_opts.keys():
opt_list = platform_opts[k]
for o in opt_list:
opts.Add(o[0],o[1],o[2])
for x in module_list:
opts.Add('module_'+x+'_enabled', "Enable module '"+x+"'.", "yes")
opts.Update(env_base) # update environment
Help(opts.GenerateHelpText(env_base)) # generate help
# add default include paths
env_base.Append(CPPPATH=['#core','#core/math','#tools','#drivers','#'])
# configure ENV for platform
env_base.detect_python=True
env_base.platform_exporters=platform_exporters
"""
sys.path.append("./platform/"+env_base["platform"])
import detect
detect.configure(env_base)
sys.path.remove("./platform/"+env_base["platform"])
sys.modules.pop('detect')
"""
if (env_base['target']=='debug'):
env_base.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC']);
env_base.Append(CPPFLAGS=['-DSCI_NAMESPACE'])
env_base.platforms = {}
for p in platform_list:
sys.path.append("./platform/"+p)
import detect
if "create" in dir(detect):
env = detect.create(env_base)
else:
env = env_base.Clone()
CCFLAGS = env.get('CCFLAGS', '')
env['CCFLAGS'] = ''
env.Append(CCFLAGS=string.split(str(CCFLAGS)))
detect.configure(env)
env['platform'] = p
sys.path.remove("./platform/"+p)
sys.modules.pop('detect')
flag_list = platform_flags[p]
for f in flag_list:
env[f[0]] = f[1]
env.module_list=[]
for x in module_list:
if env['module_'+x+'_enabled'] != "yes":
continue
tmppath="./modules/"+x
sys.path.append(tmppath)
env.current_module=x
import config
if (config.can_build(p)):
config.configure(env)
env.module_list.append(x)
sys.path.remove(tmppath)
sys.modules.pop('config')
if (env['musepack']=='yes'):
env.Append(CPPFLAGS=['-DMUSEPACK_ENABLED']);
if (env["old_scenes"]=='yes'):
env.Append(CPPFLAGS=['-DOLD_SCENE_FORMAT_ENABLED'])
if (env["rfd"]=='yes'):
env.Append(CPPFLAGS=['-DRFD_ENABLED'])
if (env["builtin_zlib"]=='yes'):
env.Append(CPPPATH=['#drivers/builtin_zlib/zlib'])
if (env['squirrel']=='yes'):
env.Append(CPPFLAGS=['-DSQUIRREL_ENABLED'])
env.Append(CPPPATH=['#script/squirrel/src'])
# to test 64 bits compiltion
# env.Append(CPPFLAGS=['-m64'])
if (env['lua']=='yes'):
env.Append(CPPFLAGS=['-DLUA_ENABLED'])
env.Append(CPPPATH=['#script/lua/src'])
if (env_base['squish']=='yes'):
env.Append(CPPFLAGS=['-DSQUISH_ENABLED']);
if (env['vorbis']=='yes'):
env.Append(CPPFLAGS=['-DVORBIS_ENABLED']);
if (env['theora']=='yes'):
env.Append(CPPFLAGS=['-DTHEORA_ENABLED']);
if (env['png']=='yes'):
env.Append(CPPFLAGS=['-DPNG_ENABLED']);
if (env['dds']=='yes'):
env.Append(CPPFLAGS=['-DDDS_ENABLED']);
if (env['pvr']=='yes'):
env.Append(CPPFLAGS=['-DPVR_ENABLED']);
if (env['jpg']=='yes'):
env.Append(CPPFLAGS=['-DJPG_ENABLED']);
if (env['webp']=='yes'):
env.Append(CPPFLAGS=['-DWEBP_ENABLED']);
if (env['speex']=='yes'):
env.Append(CPPFLAGS=['-DSPEEX_ENABLED']);
if (env['tools']=='yes'):
env.Append(CPPFLAGS=['-DTOOLS_ENABLED'])
if (env['disable_3d']=='yes'):
env.Append(CPPFLAGS=['-D_3D_DISABLED'])
if (env['gdscript']=='yes'):
env.Append(CPPFLAGS=['-DGDSCRIPT_ENABLED'])
if (env['disable_advanced_gui']=='yes'):
env.Append(CPPFLAGS=['-DADVANCED_GUI_DISABLED'])
if (env['minizip'] == 'yes'):
env.Append(CPPFLAGS=['-DMINIZIP_ENABLED'])
if (env['xml']=='yes'):
env.Append(CPPFLAGS=['-DXML_ENABLED'])
if (env['default_gui_theme']=='no'):
env.Append(CPPFLAGS=['-DDEFAULT_THEME_DISABLED'])
if (env["python"]=='yes'):
detected=False;
if (env.detect_python):
print("Python 3.0 Prefix:");
pycfg_exec="python3-config"
errorval=os.system(pycfg_exec+" --prefix")
prefix=""
if (not errorval):
#gah, why can't it get both at the same time like pkg-config, sdl-config, etc?
env.ParseConfig(pycfg_exec+" --cflags")
env.ParseConfig(pycfg_exec+" --libs")
detected=True
if (detected):
env.Append(CPPFLAGS=['-DPYTHON_ENABLED'])
#remove annoying warnings
if ('-Wstrict-prototypes' in env["CCFLAGS"]):
env["CCFLAGS"].remove('-Wstrict-prototypes');
if ('-fwrapv' in env["CCFLAGS"]):
env["CCFLAGS"].remove('-fwrapv');
else:
print("Python 3.0 not detected ("+pycfg_exec+") support disabled.");
#if env['nedmalloc'] == 'yes':
# env.Append(CPPFLAGS = ['-DNEDMALLOC_ENABLED'])
Export('env')
#build subdirs, the build order is dependent on link order.
SConscript("core/SCsub")
SConscript("servers/SCsub")
SConscript("scene/SCsub")
SConscript("tools/SCsub")
SConscript("script/SCsub");
SConscript("drivers/SCsub")
SConscript("bin/SCsub")
if env['game']:
SConscript(env['game']+'/SCsub')
SConscript("modules/SCsub")
SConscript("main/SCsub")
SConscript("platform/"+p+"/SCsub"); # build selected platform
This script collects game engine Godot (http://www.godotengine.org)
I want to convert this script in the project file of Visual Studio 2010.
In Scons have corresponding command env.MSVSProject().
Description:
Builds a Microsoft Visual Studio project file, and by default builds a solution file as well.Example usage:
barsrcs = ['bar.cpp'], barincs = ['bar.h'], barlocalincs =
['StdAfx.h'] barresources = ['bar.rc','resource.h'] barmisc =
['bar_readme.txt']
dll = env.SharedLibrary(target = 'bar.dll',
source = barsrcs)
env.MSVSProject(target = 'Bar' + env['MSVSPROJECTSUFFIX'],
srcs = barsrcs,
incs = barincs,
localincs = barlocalincs,
resources = barresources,
misc = barmisc,
buildtarget = dll,
variant = 'Release')
More - http://www.scons.org/doc/1.2.0/HTML/scons-user/a8304.html
But I do not understand how to pass the appropriate parameters, as they choose from a script.
Tell me, please.
The MSVSProject builder can create a Visual Studio project but it's only a project for you library with your files in them. You can't convert a SCons' configuration file to a VS project.
The builder only serve for people that wanted to work in Visual Studio IDE. But you need to continue compile with the scons command line tool.
There's a way to achieve what you want to achieve by properly configuring your project.
In the project's property page, under 'NMake' settings make sure that these parameters reflect the scons build command
Build command line: (eg: scons -C ....\ debug=1)
Rebuild All command line: (eg: scons -C ....\ -c && scons -C ....\ debug=1)
Clean command line: the scons command line to clean the project
These values should also be set to their proper values:
Output: (i.e. executable name)
In the project's property page, under 'General' settings make sure that these parameters correspond to:
Configuration Type: Makefile
You can find a complete description of the above at http://grbd.github.io/posts/2016/07/27/scons-builds-with-visual-studio/