How can I use cmake to compile .fx files - directx

According to this MSDN blog entry it is recommended to compile .fx effect files with fxc as part of your build process. Given a list of fx files, how do I tell cmake to add some to my project files (VS2010)?

Use find_program to find fxc and add_custom_command to build:
find_program(FXC fxc DOC "fx compiler")
if(NOT FXC)
message(SEND_ERROR "Cannot find fxc.")
endif(NOT FXC)
add_custom_target(fx ALL)
foreach(FILE foo.fx bar.fx baz.fx)
get_filename_component(FILE_WE ${FILE} NAME_WE)
add_custom_command(OUTPUT ${FILE_WE}.obj
COMMAND ${FXC} /Fo ${FILE_WE}.obj ${FILE}
MAIN_DEPENDENCY ${FILE}
COMMENT "Effect-compile ${FILE}"
VERBATIM)
add_dependencies(fx ${FILE_WE}.obj)
endforeach(FILE)
Not being a Windows user, I'm not sure if that's exactly the right way to invoke fxc, but you can tinker with it. Note also that this doesn't link the object files into wherever they need to go. This mailing list post might help you.

Related

How to get the path where the library is installed

I am working in Linux and I have a library written in Fortran 90 (written by 3rd party), that is reading from a file in the current working directory. I would like to be able to call the resulting library from other folders, hence I need to read the path where the library is installed. How can I know the path to the compiled library within the Fortran code?
I need to store in a variable the path within the code.
For who knows python, I want to achieve the same as
import os
os.path.dirname(os.path.abspath(__file__))
but in f90 (see Get location of the .py source file)
Using the suggestions in the comment I have done the following:
export DATAPATH=`pwd`
make
in the Makefile
ifort -O3 -fpic -fpp -DDATAPATH -c mysource.f90
in mysource.f90
subroutine mysub
character(len=100)::dpath
#ifdef DATAPATH
dpath=DATAPATH
#endif
open(10,file=trim(dpath)//'initialise.dat')
....
....
the problem is that at compile time I get
mysource.f90(42): error #6054: A CHARACTER data type is required in this context. [1]
dpath=1
----------^
compilation aborted for mysource.f90 (code 1)
If you wish you can fix the path at compile time. Something like
gfortran -cpp mylib.f90 -DPREFIX=\"/usr/local/\"
open(newunit=u,file=PREFIX//'mylib/initialise.dat')
You must than make sure the library is indeed installed in that place PREFIX/mylib/
You can create an environment variable containing the path of your data. This variable can be set by hand, in your .bashrc or .bash_profile or in the system /etc/profile.d/ or /etc/bash.bashrc, there are manyways and they depend if the library is just for one user or for all users of some large computer.
For example
export MYLIB_PATH='/usr/local/mylib'
Then you can read the variable in Fortran as
CALL get_environment_variable("MYLIB_PATH", mylib_path, status=stat)
and the path is now in variable mylib_path. You can check the success by checking if stat==0.
This is not the only possible approach. You can also have a configuration file for your library in your home directory:
mkdir $HOME/.config/mylib/
echo "/usr/local/mylib" > $HOME/.config/mylib/path
and then you can try to read the path from this file if the environment variable was not set
if (stat/=0) then
CALL get_environment_variable("HOME", home_dir)
open(newunit=path_unit, file=home_dir//'/.config/mylib/path',status='old',action='read',iostat=stat)
if (stat/=0) complain
read(path_unit,'(a)',iostat=stat) mylib_path
if (stat/=0) complain
end if
So when you compiled with -DDATAPATH you have not passed the variable DATAPATH into your code only declared a symbol called DATAPATH as being true, so ifort will substitute DATAPATH as 1. What you need to do is pass it as a value:
-DDATAPATH="$(DATAPATH)"
For the compilation to work.

GNU m4 macros auto generated file

I download latex package on which I want do some changes, but in this packege exist file include.m4 and I don't know what it does and how it was generated. Here its lines:
m4_changequote([[, ]])m4_dnl
m4_dnl
m4_define([[m4_FILE_INIT]], [[m4_dnl
%
% This is automaticaly generated file, do not edit it.
%
]])m4_dnl
m4_dnl
m4_define([[m4_FILE_ID]], [[m4_dnl
m4_patsubst([[$1]], [[\$Date::? \([0-9]+\)-\([0-9]+\)-\([0-9]+\).*]], [[\1/\2/\3]])m4_dnl
v[[]]m4_ESKDX_VERSION]])m4_dnl
m4_dnl
m4_define([[m4_FILE_DATE]], [[m4_dnl
m4_patsubst([[$1]], [[\$Date::? \([0-9]+\)-\([0-9]+\)-\([0-9]+\).*]], [[\1/\2/\3]])]])m4_dnl
m4_dnl
Can you explain with which tool it was generated?
Thk. So this file is not autogenerated? ANd can you help me understand these lines from Makefile:
M4FLAGS = -P -Dm4_ESKDX_INIT="m4_include($(TOP_DIR)/include.m4)" \
-Dm4_ESKDX_VERSION=$(VERSION) -Dm4_ESKDX_DATE=$(RELEASE_DATE)
And rule:
%.def: %.def.in $(M4DEPS)
m4 $(M4FLAGS) $< >$#
%.sty: %.sty.in $(M4DEPS)
m4 $(M4FLAGS) $< >$#
%.cls: %.cls.in $(M4DEPS)
m4 $(M4FLAGS) $< >$#
As I can see GNU m4 options '-D' substitutes macro m4_ESKDX_INIT in .sty .cls files to m4_include(../include.m4) and then options '-P' first expands file include.m4 and furthemore expands macros in include.m4.
This is a macro for the GNU m4 macro processor. This file is designed to be used with the -P or --prefix-builtins commandline option. The m4_ part will be stripped away when m4 evaluates this file. This file doesn't do anything itself, it just defines three macros (FILE_INIT, FILE_ID and FILE_DATE) which presumably will be used in another step. You might want to look in the other files for references to this one. The basic idea will be to load this file before running another file through m4 and it will replace those macros as it goes.
The message about automatically generated is supposed to end up in the final file as a comment. As we can see in the rules in the Makefile, each of the .def, .sty and .cls files are generated from an equivalently named .in file (so result.cls will be built from result.cls.in. by evaluating the macros in these files and replacing them with the equivalents.
So, to modify these files, you will want to edit the .in files.

Compare tool with command line for mac

I am looking for command line tool to do diff between two HTML files.
I have analysed kdiff3/command line of bbedit but my problem is dont want to open any GUI.
I want to write a java program to call command line options of the diff program to compare html files and save result in a different file or probably show in a report file.
Any pointers will be very helpful
Thanks
Vishal
If you have xcode installed, you can call up opendiff, it's a (graphical) compare tool from the command line. From it's man page:
opendiff file1 file2 [-ancestor ancestorFile] [-merge mergeFile]
opendiff dir1 dir2 [-ancestor ancestorDirectory] [-merge mergeDirectory]
I thought mac had diff built in. Have you tried using diff from the mac terminal?

Help in using OpenCV - Errors of type: identifier not found

Am a beginner to OpenCV and have gone so far as to work out the hello world samples, inverting, color conversion(RGB->greyscale ) etc programs working.
However i am stuck at the Programs that use cvCanny, cvPyr and other such feature detectors.Would really be thankful if the tiny prblem was sorted out .
I get the Error: error C3861: 'cvPyrDown': identifier not found
error C3861: 'cvCanny': identifier not found
I've included the imgproc and features2d headers yet the problem persists.
What am I missing out ?
Do you have your "Additional input directories" property set correctly?
Mine, configured by cmake, looks like this:
C:/OpenCV-2.2.0/release
C:/OpenCV-2.2.0/include
C:/OpenCV-2.2.0/include/opencv
C:/OpenCV-2.2.0/modules/core/include
C:/OpenCV-2.2.0/modules/imgproc/include
C:/OpenCV-2.2.0/modules/features2d/include
C:/OpenCV-2.2.0/modules/gpu/include
C:/OpenCV-2.2.0/modules/calib3d/include
C:/OpenCV-2.2.0/modules/objdetect/include
C:/OpenCV-2.2.0/modules/video/include
C:/OpenCV-2.2.0/modules/highgui/include
C:/OpenCV-2.2.0/modules/ml/include
C:/OpenCV-2.2.0/modules/legacy/include
C:/OpenCV-2.2.0/modules/contrib/include
C:/OpenCV-2.2.0/modules/flann/include
Btw. CMake is a nice tool if you are dealing with libraries that contains many include files, line OpenCV.
You can also check two other things:
After compiling OpenCV2.2 from sources, did you built "INSTALL" project in the OpenCV VS solution?
If you are using c++ headers, you might prefer c++ version of those functions,
in the cv namespace:
cv::Canny(...)
That sounds like a link error rather than any problems with include. Are you sure you are linking with cv.lib?
You need to add the $(OPENCV_ROOT)/lib directory to the linker path so it knows where to search for the files.
From the description, I assume you're using Visual Studio? If so, you have two options for doing so.
Add it to this project under Project -> Properties -> Linker -> General -> Additional Library Directories.
Add it for all projects: Tools -> Options -> Projects and Solutions -> VC++ Directories -> Library files. And then add folders there.

LIB file output locations for Delphi 2009 packages

When building a Delphi 2009 component package, how do you specify which directory should contain the resulting .hpp and .lib files needed for C++ Builder users?
On the Project|Options|Delphi Compiler|Linking page, the first two items are C++Builder .hpp output directory and C++Buidler .obj output directory should do what you want. The .lib and .bpi files. However, it seems that there is a bit of a bug in how these options are passed to the compiler... I'll speak with the engineer responsible about it.
From the command-line DCC32 you can use the following to control where to place these items:
-N0<path> = unit .dcu output directory
-NH<path> = unit .hpp output directory
-NO<path> = unit .obj output directory
-NB<path> = unit .bpi output directory
Note that the -NB switch AFAICR, also controls where the .lib file goes as well.
There is a known bug: http://qc.embarcadero.com/wc/qcmain.aspx?d=67513
This is /expected/ to be fixed in the forthcoming Update 3. (Don't worry about the 10.0 resolved in build number, that is a mistake that will be corrected when Update 3 is released and all the bug fixes get synchronized back to QC)
As far as I know, you can't. None of the directory options seem to control it. However, you could probably define a post-build event (Project->Options->Build events) which would copy the files to where you wanted them.

Resources