so far, my night has been extremely frustrating, trying to learn CMake. However, I'm slowly getting there. There are a couple of things bugging me though:
1) Additional Library Directories
I can either have this:
CMake: link_directories ("../../YoghurtGum/bin")
Output: AdditionalLibraryDirectories="..\..\YoghurtGum\bin\$(OutDir),..\..\YoghurtGum\bin"
Or this:
CMake: link_directories ("${PROJECT_SOURCE_DIR}../../YoghurtGum/bin")
Output: AdditionalLibraryDirectories="F:\Projects\YG3\Tests\Galaxians..\..\YoghurtGum\bin\$(OutDir),F:\Projects\YG3\Tests\Galaxians..\..\YoghurtGum\bin"
Or this:
CMake: link_directories ("${PROJECT_SOURCE_DIR}/../../YoghurtGum/bin")
Output: AdditionalLibraryDirectories="..\..\YoghurtGum\bin\$(OutDir),..\..\YoghurtGum\bin"
While what I really want is this:
Output: "..\..\YoghurtGum\bin"
2) Setting the platform name
I haven't been able to set it, but I want it to be Windows Mobile 5.0 Pocket PC SDK (ARMV4I) instead of Win32.
3) Setting the intermediate directory
I want to have this:
IntermediateDirectory="intermediate"
instead of this:
IntermediateDirectory="Galaxians.dir\Release"
but nothing seems to work.
4) Output file
It should be:
OutputFile="$(OutDir)\$(ProjectName)_debug.exe"
instead of:
OutputFile="F:\Projects\YG3\Tests\Galaxians\bin\Debug\Galaxians.exe"
Any help on any of these issues would be much appreciated.
To quote a famous (infamous?) line:
"You can't always get what you want."
1) Additional Library Directories
2) Setting the platform name
3) Setting the intermediate directory
These are just the way you've observed them. They are as they are, and you cannot change them with an "as-is" build/install of CMake.
Of course, having said that, CMake is an open source project. You could dive in and submit a patch that changes CMake to support these features. :-)
There are a few outstanding bugs (cough, feature requests) for CMake that, if fixed/implemented, would add support for other platform types. It will take quite a lot of effort to do it properly, though, and so far nobody has had the time/energy/funding to finish it off. See related CMake bug reports here:
http://public.kitware.com/Bug/view.php?id=7919
http://public.kitware.com/Bug/view.php?id=8102
http://public.kitware.com/Bug/view.php?id=8486
4) Output File
This one you can change. Set the OUTPUT_NAME or OUTPUT_NAME_DEBUG target property.
http://cmake.org/cmake/help/cmake-2-8-docs.html#prop_tgt:OUTPUT_NAME
http://cmake.org/cmake/help/cmake-2-8-docs.html#prop_tgt:OUTPUT_NAME_CONFIG
Related
I'm having difficulties trying to compile an opensource framework (EmulationStation) in VS2015 on Windows. I've never used any of the tools before, apart from Visual Studio - so please forgive me if these are some obvious mistakes.
The guide says i need to do like this:
Boost (you'll need to compile yourself or get the pre-compiled binaries)
Eigen3 (header-only library)
FreeImage
FreeType2 (you'll need to compile)
SDL2
cURL (you'll need to compile or get the pre-compiled DLL version)
(Remember to copy necessary .DLLs into the same folder as the executable: probably FreeImage.dll, freetype6.dll, SDL2.dll, libcurl.dll, and zlib1.dll. Exact list depends on if you built your libraries in "static" mode or not.)
CMake (this is used for generating the Visual Studio project)
(If you don't know how to use CMake, here are some hints: run cmake-gui and point it at your EmulationStation folder. Point the "build" directory somewhere - I use EmulationStation/build. Click configure, choose "Visual Studio [year] Project", fill in red fields as they appear and keep clicking Configure (you may need to check "Advanced"), then click Generate.)
This is how my CMake looks like (it says generating done)
I get alot of compilation errors in visual studio when trying to build though:
1) Cannot open include file: 'curl/curl.h': No such file or directory (compiling source file C:\Users\retropie\Documents\GitHub\EmulationStation\es-app\src\guis\GuiMetaDataEd.cpp) emulationstation C:\Users\retropie\Documents\GitHub\EmulationStation\es-core\src\HttpReq.h
Where do I get this header file from?
2) 'round': redefinition; different exception specifications (compiling source file C:\Users\retropie\Documents\GitHub\EmulationStation\es-app\src\guis\GuiMenu.cpp) emulationstation C:\Users\retropie\Documents\GitHub\EmulationStation\es-core\src\Util.h 18
I have a lot of these errors with round. Am I missing a reference to a library?
Another screendump of some of the errors from VS2015:
Hope someone can point me in the right direction.
I am currently in de same boat as you, trying to get ES building under MSVS2015.
I am also very green, so hopefully others chime in as well.
Regarding the 'round' errors, apparently the MS compiler has no knowledge of these. For this issue, and some others, the newer ES fork by Herdinger has fixed this.
As this is currently the most active ES branch out there, and has the explicit goal of consolidating at least some of the backlog of PRs from the original Aloshi git, I would suggest you use this one.
In issue #4, there is some more information on building in recent VS versions. There is also a link for the precompiled cURL libs, including the header.
Having gone that far, I am sad to say that I still do not have a succesfull build as of yet. Compiling is no problem, however linking gives me a LNK2005 error.
Hope this helps a bit. Let me know how you fare.
I have two projects called A and B that have complete working CMakeLists.txt projects, and each project can be built completely without errors. I would like to have a master project defined in CMake that will build both A and B (and maybe a hundred other things eventually).
My top level CMakeLists.txt project looks like
add_subdirectory(A build-A)
add_subdirectory(B build-B)
and CMake can parse all the files and make can start building just fine.
The problem is that project A is for one architecture (x86_64) and B is for a different architecture (k1om) and when CMake invokes various features like
find_package(Boost ....)
it caches the results of the library paths for the first architecture and reuses them (incorrectly!) for all subsequent architectures. We have Boost compiled for both x86_64 and k1om.
Is there a way to have CMake do what I want to do, by entirely invalidating the cache between the two projects? Something like this would be ok:
add_subdirectory(A build-A)
cmake_invalidate_cache_and_forget_everthing_that_just_happened()
add_subdirectory(B build-B)
cmake_invalidate_cache_and_forget_everthing_that_just_happened()
...
I am fully aware that I can just make a shell script that does this and just runs cmake multiple times in different output directories, but it would be really nice to have a uniform "entry" point for all projects written in CMake.
I'd recommend using a "super-build" setup whereby each subproject is included via ExternalProject_Add rather than add_subdirectory. This gives very clean separation between the subprojects' builds. I think you'd be fighting CMake very hard by trying to tinker with the generated CMakeCache.txt!
However, I've never tried actually doing this where the architecture differs between subprojects. So all I can do is suggest you try it - I think it should work.
(This article may help).
I think using ExternalProject, as Fraser suggests is the best practice for your setup, but I don't think it's going to solve the issue your having. Correct me if I'm wrong, but it sounds like you're using the same build tree for both platforms. Is that correct? If so, I can't see what can be gained from that.
If I'm wrong and you're just trying to prevent certain projects from configuring on certain architectures, then you should look into CMake's architecture blocks, like if(WIN32) ... if (CMAKE_SIZEOF_VOID_P 8) ... there are many other ways to limit code exposure base on compiler, 32 vs 64 Windows, *nix, MAC, etc ...
If I'm still not understanding, then my apologies, perhaps you can attempt a clear explanation. Perhaps all you need it the unset command for your cache variables that are incorrectly set in cache because of a different architecture. See: http://www.cmake.org/cmake/help/v3.0/command/unset.html
If that's the case though, you really should reconsider the design of your project because that approach sounds like an unmaintainable mess. Sorry.
I got it to work with ExternalProject_Add (Thank You Fraser). Here is what it looks like:
cmake_minimum_required(VERSION 2.8.4)
project(Demo1)
include(ExternalProject)
ExternalProject_Add(
A-build
SOURCE_DIR ${CMAKE_SOURCE_DIR}/A
INSTALL_COMMAND ""
)
ExternalProject_Add(
B-build
SOURCE_DIR ${CMAKE_SOURCE_DIR}/B
INSTALL_COMMAND ""
)
I'd like to use open source library on Windows. (ex:Aquila, following http://aquila-dsp.org/articles/iteration-over-wave-file-data-revisited/) But I can't understand anything about "Build System"... Everyone just say like, "Unzip the tar, do configure, make, make file" at Linux, but I want to use them for Windows. There are some several questions.
i) Why do I have to "Install" for just source code? Why can't I use these header files by copying them to the working directory and throw #include ".\aquila\global.h" ??
ii) What are Configuration and Make/Make Install? I can't understand them. I just know that configuration open source with Windows need "CMake", and it is configuration tool... But what it actually does??
iii) Though I've done : cmake, mingw32-make, mingw32-make install... My compiler said "undefined references to ...". What this means and what should I do with them?
You don't need to install for sources. You do need to install for the libraries that get built from that source code and that your code is going to use.
configure is the standard name for the script that does build configuration for the software about to be built. The usual way it is run (and how you will see it mentioned) is ./configure.
make is a build management tool (as the tag here on SO will tell you). One of the most common mechanisms for building code on linux (etc.) is to use the autotools suite which uses the aforementioned configure script to generate build configuration information for use by generated makefiles which make then uses to build the software. make is also the way to run the default build target defined in a makefile (which is often the all target and which usually builds the appropriate library/binary/etc.).
make install is a specific, secondary, invocation of the make tool on the install target which (generally) installs the (in this case previously) built code into an appropriate location (in the autotools/configure universe the default location is generally under /usr/local).
cmake is, again as the SO tag says, a build system that generates configuration files for other build tools (make, VS, etc.). This allows the developers to create the build configuration once and build on multiple platforms/etc. (at least in theory).
If running cmake worked correctly then it should have generated the correct information for whatever target system you told it to use (make or VS or whatever). Assuming that was make that should have allowed mingw32-make to build the software correctly (assuming additionally that mingw32-make is not a distinct cmake target than make). If that is not working correctly then something is still missing from your system (and cmake probably should have caught that).
But to give any more detail you will need to give more detail about what errors you are actually getting and from what command.
(Oh, and on Windows, and especially if you plan on building your software with VS (or some other non-mingw32-make tool) the chances of you needing to run mingw32-make install are incredibly small).
For Windows use cmake or latest ninja.
The process is not simple or straight, but achievable. You need to write CMake configuration.
Building process is not simple and straight, that's why there exists language like Java(that's another thing though)
Rely on CMake build the library, and you will get the Open-Source library for Windows.
You can distribute this as library for Windows systems, distribute and integrate with your own software, include the Open Source library, in either cases, you would have to build it for Windows.
Writing CMake helps, it would be helpful to build for other platforms as well.
Now Question comes: Is there any other way except CMake for Windows Build
Would you love the flavor of writing directly Assembly?
If obviously answer is no, you would have to write CMake and generate sln for MSVC and other compilers.
Just fix some of the errors comes, read the FAQ, Documentation before building an Open Source library. And fix the errors as they lurk through.
It is like handling burning iron, but it pays if you're working on something meaningful. Most of the server libraries are Open Source(e.g. age old Apache httpd). So, think before what you're doing.
There are also not many useful Open Source libraries which you could use in your project, but it's the way to Use the Open Source libraries.
I'm developing cross-platform c++ project. The original idea is to work with msvc2010 and later compile for other systems with the help of CMake and Hudson.
It doesn't seem to be convenient manually change CMake files after changes in studio settings.
So, what’s the easiest way: to write parser for vcxproj and vcxproj.filters, or there is another good solution?
It might be useful, from time to time, to do this type of conversion, say for porting. On my travels I've found the following, in no particular order:
Specifically for VS to CMake/GYP:
vcproj2cmake
vcxproj2cmake (not a typo!)
gypify.py is a .sln/solution-reading Gyp file generator. Gyp is a Cmake alternative, currently being used by the Chromium project (base for Google's Chrome browser). Gyp will output Makefile, Visual Studio or XCode build files (see Gyp's '-f [make|scons|msvc|xcode]' switch). This Python script is quite promising, I'm hoping to modify it soon to correctly specify header-containing folders for gcc's '-I' include parameter.
Other Cmake/Make-related conversion tools:
Make It So Converts Visual Studio solutions to Linux gcc makefiles
sln2mak C# project
sln2mak Perl script
GUCEF Project includes the ProjectGenerator tool, for Cmake
gencmake (ruby) – KDE Project
'pbtomake' says it can convert XCode xcodeproj/pbproj files to Makefiles (maybe outdated)
Cheers
Rich
You're coming at it backwards -- set up all your CMakeLists.txt and then generate the MSVC project from it.
It shouldn't be hard or time-consuming. Basically you just need to say which directories to look into, declare your include paths, collect your *.cpps for each library with a glob expression, and declare your dependencies.
If you have to set up anything else, then your project probably isn't very portable :-/
The best tool for this purprose is cmake-converter
I've been interested in "D" for a couple of years now and recently decided to start actually playing with it. I've been able to grasp the basics quite easily, I love the basic feature set of the language and the more I read about it, the more impressed I get.
Now, I'm very interested in writing a custom web application server as a hobby project and I want it to be a simple binary, using dynamically linked libraries for the actual web applications. I believe D to be the perfect language for this venture.
There is only one big problem... over the past couple of days, I have been completely unable to get any kind of IDE setup working. I can compile and run everything just fine on the command line, but everything I try in any of the IDE's available (Code::Blocks, eclipse+descent, Xcode with D plugin, and even the windows D-IDE running in VirtualBox on Windows XP Pro) the only thing that ever happens is:
object.d: Error: module object cannot read file 'object.d'
After two days of trying different things and following tutorials, this is really getting on my nerves. I want to learn to use D efficiently, but I need some comfy tool chain that includes code completion in the editor if I want to keep my sanity, which I obviously do.
[edit:added emphasis to the really important bit]
Is there anyone that can help me set up eclipse or (preferably) netbeans (but no plugin seems to be publicly available) to give me compile and run abilities in the IDE, along with code completion? on my Mac, running Mac OS X 10.6?
I want to use the phobos libraries (and therefor a 2.0 compiler) but I don't really care if its dmd or gdmd (gdcmac).
[addition]
I believe we can assume that my dmd compiler installation is in order because it works from the commandline. I just don't want to use it from the commandline because its tedious. The question is about and IDE, the compiler works, its just IDEs that won't
Well, the persistent bugger in me could not leave the problem alone and I finally got it to work.
The required components to get it all working on Mac OS X 10.6 are:
DMD compiler
Eclipse "Galileo" (version 3.4)
Descent
DSSS
a change to /usr/etc/rebuild/default
a new file i hacked together /usr/etc/rebuild/macosx.conf
global and per-project settings for Eclipse
After following these instructions you'll have Eclipse able to do code completion on your D projects and you'll be able to build/run from within the IDE as well.
The actual steps to get it operational are as follows.
install the digitalmars dmd 2.0 compiler
download the binary distribution from digitalmars.com (direct link to 2.041)
unzip the downloaded file into ~/somefolder (that created a ~/somefolder/dmd2 folder for me which I'll use for the duration of this example.)
in the terminal (/Applications/Utilities/Terminal.app) move the files to their destination
sudo mv ~/somefolder/dmd2/osx/bin/* /usr/bin/ enter your login password when asked
move the just copied dmd.conf to its location: sudo mv /usr/bin/dmd.conf /etc/dmd.conf
sudo mv ~/somefolder/dmd2/osx/lib/* /usr/lib/
sudo mv ~/somefolder/dmd2 /usr/
use your favorite text editor to edit /etc/dmd.conf to contain the following:
[Environment]
DFLAGS=-I/usr/dmd2/src/phobos -I/usr/dmd2/src/druntime/import -L-L/usr/lib
Download and install your favorite Mac OS X version of eclipse out of the umpteen hundreds available at http://www.eclipse.org/downloads/ (I picked a cocoa version for c/c++)
Install Descent (almost as per the normal instructions in the wiki)
run Eclipse (don't bother running as root)
goto Help -> Install New Software from the menu bar. (wtf does that do in the Help menu?!)
copy/paste http://downloads.dsource.org/projects/descent/update-site into the url field.
follow on screen instructions to finish installation.
install dsss from sourceforge (direct link to .dmg)
use the installer package on the disk image like any other.
create a file /usr/etc/rebuild/macosx.conf and paste the following snippet into it. (and save, duh)
profile=phobos
compiler=dmd
inifile=dmd.conf
exeext=
objext=o
version=DigitalMars
noversion=GNU
version=MacOSX
version=linux
noversion=Unix
noversion=Posix
noversion=Windows
noversion=Win32
noversion=Win64
version=X86
noversion=PPC
noversion=X86_64
version=D_InlineAsm
version=D_InlineAsm_X86
noversion=D_InlineAsm_PPC
noversion=D_InlineAsm_X86_64
version=LittleEndian
noversion=BigEndian
[compile]
cmd=dmd -version=MacOSX -c $i
flag=$i
incdir=-I$i
libdir=-L-L$i
optimize=-O
version=-version=$i
[link]
oneatatime=yes
#cmd=dmd -L-lphobos $i -of$o
cmd=dmd $i -of$o
# cmd=dmd -L--start-group -L-lphobos $i -of$o
libdir=-L-L$i
lib=-L-l$i
flag=-L$i
[liblink]
safe=yes
oneatatime=yes
cmd=if [ ! -z "$o" ]; then ar rc $o $i; fi
libdir=
lib=
flag=
[postliblink]
cmd=ranlib $i
[shliblink]
shlibs=no
[dyliblink]
dylibs=no
change the /usr/etc/rebuild/default file to read: profile=dmd-macosx
Set up Eclipse to have code completion
In the global eclipse preferences navigate tp D => Build Path => User Libraries
click New, type "std", press OK select the newly created entry, click Add Directory
navigate to /usr/dmd2/src/phobos/std and add it.
Set up Eclipse project.
You have to do this manually for every D project you'll make
Create a new project with the "D => D Project" wizard (thanks to Descent)
Go into project properties (right click project in the Project Explorer and choose Properties)
In the list to the left select D Build Path and in the panel that appears choose the Include Path tab.
Click the Add Library button and choose std in the second page of the wizard.
Configure the extarnal build tool
Go to External tools configurations... (from the dropdown in the little green play button with the toolbox in front of it in the build/run/debug toolbar thingy)
In the list to the left right click Program and choose New from the context menu.
give your config a decent name like "Build with dsss" and set the following options:
Location: /usr/bin/dsss
Working Directory: full path to directory with your dsss.conf file for the project
(if you don't have a dsss.conf file create one on the commandline: dsss genconfig)
Arguments: build (or rebuild, or clean, or...)
repeat steps 2 and 3 above for as many build/run options as you require.
Congratulations, everything should work now.
If for some reason this does not work for you, let me know and I'll be happy to figure out where it went wrong and help you to get it working. If there's a better or simpler way, I'd love to know about it as well.
object.d: Error: module object cannot read file 'object.d'
clearly indicates that it can't find the libraries properly. So, the first question is how your dmd.conf is set up. You need to make sure that it's pointing to the correct places for src/phobos, src/druntime/import, and osx/lib - wherever you put those. Personally, I put the dmd code in a subfolder of home and don't try and install it in /usr, but the instructions do tell you to install them there as the default, so it should work.
Assuming that your dmd.conf looks okay, the most likely situation is that it's actually using the wrong dmd.conf. Per the instructions on the digital mars site ( http://www.digitalmars.com/d/2.0/dmd-osx.html ):
dmd will look for the initialization file dmd.conf in the following sequence of directories:
1. current working directory
2. directory specified by the HOME environment
3. variable directory dmd resides in
4. /etc/
My guess is that you put dmd.conf in /etc and have been editing that one but left the original dmd.conf in
/where_dmd_is/dmd2/osx/bin/
Certainly, I've had that happen to me a time or two. In any case, the first thing that you need to make sure of is that the dmd.conf that you're editing is the one that dmd is using (so make sure that the places where dmd looks first don't have a dmd.conf), and the second thing that you need to make sure of is that the paths in your dmd.conf correctly point to where the dmd stuff is. If those two things are correct, then dmd should find the libraries correctly.
On a side note, I would point out, however, given your comment about wanting to use shared libraries is that shared libraries don't work correctly with D2 right now (I have no idea whether they work with D1 since I don't use D1 - I suspect that they don't though). There have been discussions about it on the D newsgroup ( http://www.digitalmars.com/NewsGroup.html ), so you can look there. It is something on the radar and is being looked into, but doesn't fully work yet. Also, you can look to the newsgroup for further help on D-related issues. It's probably the best place to ask right now.
If it's a question of an IDE, as far as eclipse goes, I believe that the plugin to look at is descent: http://www.dsource.org/projects/descent
Unfortunately, I haven't tried it myself yet, so I don't know how good it is. According to its wiki page, it's primarily intended for D1 but does support D2 to at least some extent.
If you wanna get started quickly (aka Double-click-install): D for Xcode
Requirements:
Xcode
That's it. Installs the latest dmd compiler, so it works in Terminal too etc.
As i keep seeing this question coming back in my search results every now and then, I figured I'd keep it relevant.
Nowadays; In the Mountain Lion era, a much easier solution exists in the Mono-D project
Just install MonoDevelop (or Xamarin Studio) and follow the five minute installation manual
(You can use Phobos on D 1.0. Anyway…)
Where did you install the Phobos and druntime headers?
<the .zip file>/src/druntime/
<the .zip file>/src/phobos/
Usually I copy them into /usr/include.
(Also, try to edit dmd.conf to use the absolute path:
[Environment]
DFLAGS=-I/usr/include/phobos -I/usr/include/druntime/import -L-L/usr/lib
)